Skip to content

Commit

Permalink
fix(renterd,hostd): contract showing empty renewed from to IDs
Browse files Browse the repository at this point in the history
  • Loading branch information
alexfreska committed Dec 11, 2024
1 parent 650c2b4 commit 5673599
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/fresh-actors-deny.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'hostd': patch
---

Contracts that have not been renewed from or two another contract no longer show the empty contract ID in the contract ID table cell.
5 changes: 5 additions & 0 deletions .changeset/fresh-mice-sneeze.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'renterd': patch
---

Contracts that have not been renewed from another contract no longer show the empty contract ID in the contract ID table cell.
10 changes: 9 additions & 1 deletion apps/hostd-e2e/src/specs/contracts.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { test, expect } from '@playwright/test'
import { navigateToContracts } from '../fixtures/navigate'
import { afterTest, beforeTest } from '../fixtures/beforeTest'
import { getContractRowsAll } from '../fixtures/contracts'
import { getContractRows, getContractRowsAll } from '../fixtures/contracts'

test.beforeEach(async ({ page }) => {
await beforeTest(page, {
Expand All @@ -27,3 +27,11 @@ test('contracts bulk integrity check', async ({ page }) => {
page.getByText('Integrity checks started for 2 contracts')
).toBeVisible()
})

test('new contracts do not show a renewed from or to contract', async ({
page,
}) => {
await navigateToContracts(page)
await expect(getContractRows(page).getByTestId('renewedFrom')).toBeHidden()
await expect(getContractRows(page).getByTestId('renewedTo')).toBeHidden()
})
2 changes: 2 additions & 0 deletions apps/hostd/contexts/contracts/columns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export const columns: ContractsTableColumn[] = (
<ArrowUpLeft16 className="scale-75" />
</Text>
<ValueCopyable
testId="renewedFrom"
color="subtle"
size="10"
type="contract"
Expand All @@ -95,6 +96,7 @@ export const columns: ContractsTableColumn[] = (
<ArrowDownRight16 className="scale-75" />
</Text>
<ValueCopyable
testId="renewedTo"
color="subtle"
size="10"
value={stripPrefix(renewedTo)}
Expand Down
5 changes: 3 additions & 2 deletions apps/hostd/contexts/contracts/dataset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export function useDataset({
}

function getContractFields(c: Contract): ContractData {
console.log(c.renewedFrom, c.renewedTo)
const accountFunding = new BigNumber(c.usage.accountFunding || 0)
const egress = new BigNumber(c.usage.egress || 0)
const ingress = new BigNumber(c.usage.ingress || 0)
Expand Down Expand Up @@ -91,9 +92,9 @@ function getContractFields(c: Contract): ContractData {
renewedFrom: c.renewedFrom,
isRenewedFrom:
c.renewedFrom !==
'fcid:0000000000000000000000000000000000000000000000000000000000000000',
'0000000000000000000000000000000000000000000000000000000000000000',
isRenewedTo:
c.renewedTo !==
'fcid:0000000000000000000000000000000000000000000000000000000000000000',
'0000000000000000000000000000000000000000000000000000000000000000',
}
}
6 changes: 6 additions & 0 deletions apps/renterd-e2e/src/specs/contracts.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { navigateToContracts } from '../fixtures/navigate'
import { afterTest, beforeTest } from '../fixtures/beforeTest'
import {
getContractRowByIndex,
getContractRows,
getContractRowsAll,
getContractsSummaryRow,
} from '../fixtures/contracts'
Expand Down Expand Up @@ -145,3 +146,8 @@ test('contracts bulk blocklist', async ({ page }) => {
await dialog.getByLabel('view allowlist').click()
await expect(dialog.getByText('The allowlist is empty')).toBeVisible()
})

test('new contracts do not show a renewed from', async ({ page }) => {
await navigateToContracts({ page })
await expect(getContractRows(page).getByTestId('renewedFrom')).toBeHidden()
})
1 change: 1 addition & 0 deletions apps/renterd/contexts/contracts/columns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ export const columns: ContractsTableColumn[] = [
<ArrowUpLeft16 className="scale-75" />
</Text>
<ValueCopyable
testId="renewedFrom"
color="subtle"
size="10"
type="contract"
Expand Down
2 changes: 1 addition & 1 deletion apps/renterd/contexts/contracts/dataset.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export function useDataset() {
response.data?.map((c) => {
const isRenewed =
c.renewedFrom !==
'fcid:0000000000000000000000000000000000000000000000000000000000000000'
'0000000000000000000000000000000000000000000000000000000000000000'
const startTime = blockHeightToTime(currentHeight, c.startHeight)
const endHeight = c.windowStart
const endTime = blockHeightToTime(currentHeight, endHeight)
Expand Down

0 comments on commit 5673599

Please sign in to comment.