Skip to content

Commit

Permalink
refactor: remove sia central
Browse files Browse the repository at this point in the history
  • Loading branch information
alexfreska committed Feb 25, 2025
1 parent 2bdac41 commit 0745508
Show file tree
Hide file tree
Showing 100 changed files with 789 additions and 1,934 deletions.
1 change: 0 additions & 1 deletion .changeset/ten-geckos-rest.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
---
'@siafoundation/e2e': minor
'@siafoundation/sia-central-mock': minor
'@siafoundation/walletd-mock': minor
---

Upgraded playwright dependencies.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@ The Sia web libraries provide developers with convenient TypeScript SDKs for usi
- [explorer-e2e](apps/explorer-e2e) - App for testing explorer.
- [e2e](libs/e2e) - Shared e2e testing code.
- [@siafoundation/clusterd](libs/clusterd) - Methods for controlling `clusterd` in e2e testing.
- [@siafoundation/walletd-mock](libs/walletd-mock) - `walletd` data and API mock library for testing.
- [@siafoundation/sia-central-mock](libs/sia-central-mock) - Sia Central data and API mock library for testing.

## Development

Expand Down
4 changes: 2 additions & 2 deletions apps/hostd-e2e/src/fixtures/beforeTest.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { mockApiSiaCentralHostsNetworkAverages } from '@siafoundation/sia-central-mock'
import { login } from './login'
import { Page } from 'playwright'
import {
Expand All @@ -11,11 +10,12 @@ import {
clickIf,
setCurrencyDisplay,
mockApiSiaScanExchangeRates,
mockApiSiaScanHostMetrics,
} from '@siafoundation/e2e'

export async function beforeTest(page: Page, { renterdCount = 0 } = {}) {
await mockApiSiaScanExchangeRates({ page })
await mockApiSiaCentralHostsNetworkAverages({ page })
await mockApiSiaScanHostMetrics({ page })
await setupCluster({ hostdCount: 1, renterdCount })
const hostdNode = clusterd.nodes.find((n) => n.type === 'hostd')
await hostdWaitForContracts({ hostdNode, renterdCount })
Expand Down
6 changes: 3 additions & 3 deletions apps/hostd/components/CmdRoot/AppCmdGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ export function AppCmdGroup({ currentPage, parentPage }: Props) {
currentPage={currentPage}
commandPage={commandPage}
onSelect={() => {
setExternalDataSettings({ siaCentral: !settings.siaCentral })
setExternalDataSettings({ siascan: !settings.siascan })
closeDialog()
}}
>
{(settings.siaCentral ? 'Disable' : 'Enable') +
' external API - Sia Central exchange rates'}
{(settings.siascan ? 'Disable' : 'Enable') +
' external API - Siascan exchange rates'}
</CommandItemSearch>
<CommandItemRootAndSearch
currentPage={currentPage}
Expand Down
4 changes: 2 additions & 2 deletions apps/renterd-e2e/src/fixtures/beforeTest.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { login } from './login'
import { Page } from 'playwright'
import { mockApiSiaCentralHostsNetworkAverages } from '@siafoundation/sia-central-mock'
import {
clusterd,
setupCluster,
Expand All @@ -11,11 +10,12 @@ import {
setCurrencyDisplay,
mockApiSiaScanExchangeRates,
clickIf,
mockApiSiaScanHostMetrics,
} from '@siafoundation/e2e'

export async function beforeTest(page: Page, { hostdCount = 0 } = {}) {
await mockApiSiaScanExchangeRates({ page })
await mockApiSiaCentralHostsNetworkAverages({ page })
await mockApiSiaScanHostMetrics({ page })
await setupCluster({ renterdCount: 1, hostdCount })
const renterdNode = clusterd.nodes.find((n) => n.type === 'renterd')
await renterdWaitForContracts({ renterdNode, hostdCount })
Expand Down
18 changes: 8 additions & 10 deletions apps/renterd-e2e/src/specs/externalData.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@ import { test, expect } from '@playwright/test'
import { afterTest } from '../fixtures/beforeTest'
import { clusterd, setupCluster } from '@siafoundation/clusterd'
import { login } from '../fixtures/login'
import {
mockApiSiaCentralHostsNetworkAverages,
mockApiSiaCentralHostsNetworkAveragesHanging,
mockApiSiaCentralHostsNetworkAveragesUnroute,
} from '@siafoundation/sia-central-mock'
import { configResetBasicSettings } from '../fixtures/configResetSettings'
import {
expectTextInputByName,
Expand All @@ -15,11 +10,14 @@ import {
mockApiSiaScanExchangeRatesUnroute,
mockApiSiaScanExchangeRatesHanging,
fillSelectInputByName,
mockApiSiaScanHostMetrics,
mockApiSiaScanHostMetricsUnroute,
mockApiSiaScanHostMetricsHanging,
} from '@siafoundation/e2e'

test.beforeEach(async ({ page }) => {
await mockApiSiaScanExchangeRates({ page })
await mockApiSiaCentralHostsNetworkAverages({ page })
await mockApiSiaScanHostMetrics({ page })
await setupCluster({ renterdCount: 1 })
const renterdNode = clusterd.nodes.find((n) => n.type === 'renterd')
await login({
Expand Down Expand Up @@ -83,8 +81,8 @@ test('configuration shows not-enabled message when exchange rates API hangs', as
test('configuration does not show network averages when sia central API hangs', async ({
page,
}) => {
await mockApiSiaCentralHostsNetworkAveragesUnroute({ page })
await mockApiSiaCentralHostsNetworkAveragesHanging({ page })
await mockApiSiaScanHostMetricsUnroute({ page })
await mockApiSiaScanHostMetricsHanging({ page })
await page.reload()

await fillSelectInputByName(page, 'pinnedCurrency', 'usd')
Expand Down Expand Up @@ -120,8 +118,8 @@ test('configuration does not show network averages when sia central API hangs',
page.getByTestId('maxDownloadPriceTBGroup').getByText('Network average')
).toBeHidden()

await mockApiSiaCentralHostsNetworkAveragesUnroute({ page })
await mockApiSiaCentralHostsNetworkAverages({ page })
await mockApiSiaScanHostMetricsUnroute({ page })
await mockApiSiaScanHostMetrics({ page })
await page.reload()

// Regular field should be shown.
Expand Down
6 changes: 3 additions & 3 deletions apps/renterd/components/CmdRoot/AppCmdGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ export function AppCmdGroup({ currentPage, parentPage }: Props) {
currentPage={currentPage}
commandPage={commandPage}
onSelect={() => {
setExternalDataSettings({ siaCentral: !settings.siaCentral })
setExternalDataSettings({ siascan: !settings.siascan })
closeDialog()
}}
>
{(settings.siaCentral ? 'Disable' : 'Enable') +
' external API - Sia Central exchange rates'}
{(settings.siascan ? 'Disable' : 'Enable') +
' external API - Siascan exchange rates'}
</CommandItemSearch>
<CommandItemRootAndSearch
currentPage={currentPage}
Expand Down
46 changes: 17 additions & 29 deletions apps/renterd/components/Hosts/HostMap/HostItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,15 @@ import {
} from '@siafoundation/design-system'
import { cx } from 'class-variance-authority'
import BigNumber from 'bignumber.js'
import { SiaCentralHost } from '@siafoundation/sia-central-types'
import {
monthsToBlocks,
TBToBytes,
humanBytes,
humanSiacoin,
getDownloadSpeed,
getUploadSpeed,
} from '@siafoundation/units'
import { ExplorerHost } from '@siafoundation/explored-types'

type Host = SiaCentralHost
type Host = ExplorerHost

type Props = {
host: Host
Expand All @@ -39,14 +37,14 @@ export function HostItem({
const storageCost = useMemo(
() =>
rates
? `$${new BigNumber(host.settings?.storage_price || 0)
? `$${new BigNumber(host.settings?.storageprice || 0)
.times(TBToBytes(1))
.times(monthsToBlocks(1))
.div(1e24)
.times(rates?.usd || 1)
.toFixed(2)}/TB`
: `${humanSiacoin(
new BigNumber(host.settings?.storage_price || 0)
new BigNumber(host.settings?.storageprice || 0)
.times(TBToBytes(1))
.times(monthsToBlocks(1)),
{ fixed: 0 }
Expand All @@ -57,13 +55,13 @@ export function HostItem({
const downloadCost = useMemo(
() =>
rates
? `$${new BigNumber(host.settings?.download_price || 0)
? `$${new BigNumber(host.settings?.downloadbandwidthprice || 0)
.times(TBToBytes(1))
.div(1e24)
.times(rates?.usd || 1)
.toFixed(2)}/TB`
: `${humanSiacoin(
new BigNumber(host.settings?.download_price || 0).times(
new BigNumber(host.settings?.downloadbandwidthprice || 0).times(
TBToBytes(1)
),
{ fixed: 0 }
Expand All @@ -74,13 +72,15 @@ export function HostItem({
const uploadCost = useMemo(
() =>
rates
? `$${new BigNumber(host.settings?.upload_price || 0)
? `$${new BigNumber(host.settings?.uploadbandwidthprice || 0)
.times(TBToBytes(1))
.div(1e24)
.times(rates?.usd || 1)
.toFixed(2)}/TB`
: `${humanSiacoin(
new BigNumber(host.settings?.upload_price || 0).times(TBToBytes(1)),
new BigNumber(host.settings?.uploadbandwidthprice || 0).times(
TBToBytes(1)
),
{ fixed: 0 }
)}/TB`,
[rates, host]
Expand All @@ -91,7 +91,7 @@ export function HostItem({
content={
<div className="flex flex-col gap-1">
<Text size="12" color="contrast" weight="bold">
{countryCodeEmoji(host.country_code)} {host.country_code}
{countryCodeEmoji(host.countryCode)} {host.countryCode}
</Text>
<div className="flex gap-2">
<div className="flex flex-col gap-1">
Expand All @@ -105,17 +105,6 @@ export function HostItem({
upload
</Text>
</div>
<div className="flex flex-col gap-1">
<Text size="12" color="contrast">
{humanBytes(host.settings?.total_storage || 0)}
</Text>
<Text size="12" color="contrast">
{getDownloadSpeed(host)}
</Text>
<Text size="12" color="contrast">
{getUploadSpeed(host)}
</Text>
</div>
<div className="flex flex-col gap-1">
<Text size="12" color="contrast">
{storageCost}
Expand All @@ -130,7 +119,7 @@ export function HostItem({
</div>
</div>
}
key={host.public_key}
key={host.publicKey}
>
<Button
variant="ghost"
Expand All @@ -140,30 +129,29 @@ export function HostItem({
}
}}
onClick={() => {
selectActiveHost(host.public_key)
selectActiveHost(host.publicKey)
}}
className={cx(
'flex gap-1',
host.public_key === activeHost?.public_key
host.publicKey === activeHost?.publicKey
? 'opacity-100'
: 'opacity-50',
'hover:opacity-100'
)}
>
<Text size="12" noWrap>
{countryCodeEmoji(host.country_code)}
{countryCodeEmoji(host.countryCode)}
</Text>
<Text
color="contrast"
size="12"
className="text-white"
noWrap
weight={
host.public_key === activeHost?.public_key ? 'semibold' : 'regular'
host.publicKey === activeHost?.publicKey ? 'semibold' : 'regular'
}
>
{humanBytes(host.settings?.total_storage || 0)}
{host.benchmark && ` · ${getDownloadSpeed(host)}`}
{humanBytes(host.settings?.totalstorage || 0)}
{' · '}
{storageCost}
</Text>
Expand Down
2 changes: 1 addition & 1 deletion apps/renterd/components/Hosts/HostMap/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export function HostMap() {
const { gpu, settings } = useAppSettings()
const { setCmd, activeHost, onHostMapClick, hostsWithLocation } = useHosts()

if (settings.siaCentral && !gpu.shouldRender) {
if (settings.siascan && !gpu.shouldRender) {
return null
}

Expand Down
6 changes: 3 additions & 3 deletions apps/renterd/components/Hosts/HostsActionsMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ export function HostsActionsMenu() {
</Button>
<Tooltip
content={
!settings.siaCentral
? 'Enable Sia Central to view interactive map'
!settings.siascan
? 'Enable Siascan to view interactive map'
: gpu.canGpuRender && gpu.isGpuEnabled
? 'Toggle interactive map'
: 'Enable GPU to view interactive map'
Expand All @@ -30,7 +30,7 @@ export function HostsActionsMenu() {
<Button
disabled={!gpu.canGpuRender}
onClick={() => {
if (!settings.siaCentral) {
if (!settings.siascan) {
openDialog('settings')
return
}
Expand Down
5 changes: 0 additions & 5 deletions apps/renterd/contexts/config/transform.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -375,11 +375,6 @@ describe('tansforms', () => {
gouging: { data: gouging },
pinned: { data: pinned },
upload: { data: upload },
appSettings: {
settings: {
siaCentral: false,
},
},
},
renterdState: {
network: 'mainnet' as const,
Expand Down
Loading

0 comments on commit 0745508

Please sign in to comment.