Skip to content

Commit

Permalink
Merge pull request #136 from Juneo-io/testUpdate
Browse files Browse the repository at this point in the history
Test update
  • Loading branch information
alekswaslet authored Jun 20, 2024
2 parents 524f0db + 7a38ee6 commit 72a77a7
Show file tree
Hide file tree
Showing 10 changed files with 75 additions and 72 deletions.
5 changes: 2 additions & 3 deletions tests/e2e/api/info.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { GenesisJUNEChain } from '../../../src'
import { PROVIDER } from '../constants'

describe('InfoAPI', () => {
describe('isBootstrapped', () => {
test.each([{ chainID: GenesisJUNEChain.id }])('Valid: $chainID', async ({ chainID }) => {
test.each([{ chainID: PROVIDER.juneChain.id }])('Valid: $chainID', async ({ chainID }) => {
const result = await PROVIDER.info.isBootstrapped(chainID)
expect(result.isBootstrapped).toEqual(true)
})
Expand All @@ -15,7 +14,7 @@ describe('InfoAPI', () => {
describe('getBlockchainID', () => {
test.each([{ alias: 'JUNE' }])('Valid: $alias', async ({ alias }) => {
const result = await PROVIDER.info.getBlockchainID(alias)
expect(result.blockchainID).toEqual(GenesisJUNEChain.id)
expect(result.blockchainID).toEqual(PROVIDER.juneChain.id)
})
test.failing.each([{ alias: 'WRONG_ALIAS' }])('Invalid: $alias', async ({ alias }) => {
await PROVIDER.info.getBlockchainID('alias')
Expand Down
16 changes: 8 additions & 8 deletions tests/e2e/api/jevm.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { GenesisEUROC1Asset, GenesisJUNEChain } from '../../../src'
import { SocotraEUR1Asset } from '../../../src'
import { PROVIDER } from '../constants'

describe('JEVMAPI', () => {
Expand All @@ -8,7 +8,7 @@ describe('JEVMAPI', () => {
{ txID: '0x3c529e9941b6ca0ec34948c7f797e94ff810643ef64896c409ea0df36be9e554' },
{ txID: 'INVALID_TX_ID' }
])('Invalid: $txID', async ({ txID }) => {
const result = await PROVIDER.jevmApi[GenesisJUNEChain.id].getTx(txID)
const result = await PROVIDER.jevmApi[PROVIDER.juneChain.id].getTx(txID)
expect(result.tx).toBeDefined()
})
})
Expand All @@ -19,13 +19,13 @@ describe('JEVMAPI', () => {
description: 'Wrong address',
address: '0x9b31d8C5Dd49fCdE96218895f96a6eC894529',
block: '0x4BF7C5',
assetID: GenesisEUROC1Asset.assetId
assetID: SocotraEUR1Asset.assetId
},
{
description: 'Wrong block',
address: '0x9b31d8C5Dd49fCdE96218895f96a6eC1ea894529',
block: '2000',
assetID: GenesisEUROC1Asset.assetId
assetID: SocotraEUR1Asset.assetId
},
{
description: 'Wrong assetID',
Expand All @@ -34,27 +34,27 @@ describe('JEVMAPI', () => {
assetID: '0x0'
}
])('$description: $address, $block, $assetID', async ({ address, block, assetID }) => {
await PROVIDER.jevmApi[GenesisJUNEChain.id].eth_getAssetBalance(address, block, assetID)
await PROVIDER.jevmApi[PROVIDER.juneChain.id].eth_getAssetBalance(address, block, assetID)
})
})

describe('eth_baseFee', () => {
test('Returns base fee', async () => {
const result = await PROVIDER.jevmApi[GenesisJUNEChain.id].eth_baseFee()
const result = await PROVIDER.jevmApi[PROVIDER.juneChain.id].eth_baseFee()
expect(result).toBeDefined()
})
})

describe('eth_maxPriorityFeePerGas', () => {
test('Returns max priority fee per gas', async () => {
const result = await PROVIDER.jevmApi[GenesisJUNEChain.id].eth_maxPriorityFeePerGas()
const result = await PROVIDER.jevmApi[PROVIDER.juneChain.id].eth_maxPriorityFeePerGas()
expect(result).toBeDefined()
})
})

describe('eth_getChainConfig', () => {
test('Returns chain config', async () => {
const result = await PROVIDER.jevmApi[GenesisJUNEChain.id].eth_getChainConfig()
const result = await PROVIDER.jevmApi[PROVIDER.juneChain.id].eth_getChainConfig()
expect(result).toBeDefined()
})
})
Expand Down
11 changes: 5 additions & 6 deletions tests/e2e/api/jvm.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {
GenesisBCH1Asset,
GenesisETH1Asset,
GenesisJUNEAsset,
SocotraBCH1Asset,
SocotraEUR1Asset,
type GetAssetDescriptionResponse,
type GetBlockResponse,
type GetHeightResponse,
Expand All @@ -15,7 +14,7 @@ describe('JVMAPI', () => {
})

describe('getAssetDescription', () => {
test.each([{ asset: GenesisJUNEAsset }, { asset: GenesisETH1Asset }, { asset: GenesisBCH1Asset }])(
test.each([{ asset: PROVIDER.jvmChain.asset }, { asset: SocotraEUR1Asset }, { asset: SocotraBCH1Asset }])(
'Valid: $asset.assetId ($asset.symbol)',
async ({ asset }) => {
const result: GetAssetDescriptionResponse = await PROVIDER.jvmApi.getAssetDescription(asset.assetId)
Expand Down Expand Up @@ -69,8 +68,8 @@ describe('JVMAPI', () => {

describe('getTx', () => {
test.each([
{ txID: 'dGJVWGj3GHQRAvt87xqcVUwKNKcJRaB7iUwGpNP9PYSrk6rie' },
{ txID: '2FKNX3WoJwtbanNxVV44qaXsv8SgkiBtD4psHC2wdbLizXvGS' }
{ txID: 'P1ogBpExP9gRM2Pjqr7J32bzACcob4hZtEj62T71feW6Q8KGb' },
{ txID: '2E5DxrCSQkAc1FoAQ7q1QQyaHnHskEkvDjzFG9YYN7dfsjKGjB' }
])('Valid: $txID', async ({ txID }) => {
const result: GetTxResponse = await PROVIDER.jvmApi.getTx(txID)
expect(result.encoding).toBeDefined()
Expand Down
27 changes: 14 additions & 13 deletions tests/e2e/api/platform.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { GenesisBCH1Chain, GenesisJUNEChain, type GetBlockResponse } from '../../../src'
import { SocotraBCH1Chain, type GetBlockResponse } from '../../../src'
import { PROVIDER } from '../constants'

describe('PlatformAPI', () => {
describe('getBlock', () => {
test.each([
{ blockID: '2qbN8EiGKprtFLkQxnQMgqbXSWdui5rwVUTsQp5Z5RYFphy1oK' },
{ blockID: '2K8nAXkMwgnJRCFMAS7KiJSkBbDYKtFP6JH7ww2YiAjg6XnN69' }
{ blockID: '25ttEN33bZ4nj2TYUWYrMrmx3jShwGQwsakjckPvk75FXnPKx' },
{ blockID: '8uUGsfz6PfnLqF5H3FA6PkkcVv5bZ7o35SgBX1VcrLgEGEdn7' }
])('Valid blockID: $blockID', async ({ blockID }) => {
const result: GetBlockResponse = await PROVIDER.platformApi.getBlock(blockID)
expect(result.block).toBeDefined()
Expand All @@ -31,8 +31,8 @@ describe('PlatformAPI', () => {

describe('getBlockchainStatus', () => {
test.each([
{ blockchainID: GenesisJUNEChain.id },
{ blockchainID: GenesisBCH1Chain.id },
{ blockchainID: PROVIDER.juneChain.id },
{ blockchainID: SocotraBCH1Chain.id },
{ blockchainID: '2k1EyxAV5XYPxnsuPVrKyquUTLC3EMA1c5AhM7r8sRy1Kg7Zje' }
])('Valid blockchainID: $blockchainID', async ({ blockchainID }) => {
const result = await PROVIDER.platformApi.getBlockchainStatus(blockchainID)
Expand Down Expand Up @@ -108,7 +108,7 @@ describe('PlatformAPI', () => {
{ description: 'Invalid supernetID', supernetID: 'INVALID_SUPERNET_ID' },
{
description: 'Permissionned supernet supernetID',
supernetID: 'ZLfejkjx2AwkaNbGC7oQxX3gE6G1YLs4FzMimQEG6Us2b7UpW'
supernetID: 'qyieai1WRqtxqKwn8CUUAfgXfu6rQbHJhiiLE6DpCWHXtHTGG'
}
])('$description: $supernetID', async ({ supernetID }) => {
await PROVIDER.platformApi.getMinStake(supernetID as any)
Expand Down Expand Up @@ -157,7 +157,7 @@ describe('PlatformAPI', () => {
{ description: 'Invalid supernetID', supernetID: 'INVALID_SUPERNET_ID' },
{
description: 'Permissionned supernet supernetID',
supernetID: 'ZLfejkjx2AwkaNbGC7oQxX3gE6G1YLs4FzMimQEG6Us2b7UpW'
supernetID: 'ZLfejkjx2AwkaNbGC7oQxX3gE6G1YLs4FzMimQEG6Us2bUpW'
}
])('$description: $supernetID', async ({ supernetID }) => {
await PROVIDER.platformApi.getTotalStake(supernetID as any)
Expand All @@ -166,8 +166,8 @@ describe('PlatformAPI', () => {

describe('getTx', () => {
test.each([
{ txID: '2tCUnxobnWD6PgRMVaBJt6uiUxk9NcjLU6Emczbj64GF7dnkcp' },
{ txID: '27xs3BGknXSSKg86rczsFCHTvDLQ4dcH9BrgSwKepQcYB5VGc3' }
{ txID: '2G5dJ1kQFu7S6pJTffKqcnfVGNcFGCmtZE3D3fCPDSQuCRrM5p' },
{ txID: 'V39EFBBf2yXLqacsmFrM1WRhvtHfMa55LY2CwFsVLDK64sKXG' }
])('Valid txID: $txID', async ({ txID }) => {
const result = await PROVIDER.platformApi.getTx(txID)
expect(result.encoding).toBeDefined()
Expand Down Expand Up @@ -203,7 +203,8 @@ describe('PlatformAPI', () => {
describe('getValidatorsAt', () => {
test.each([{ height: 100 }, { height: 200 }])('Valid height: $height', async ({ height }) => {
const result = await PROVIDER.platformApi.getValidatorsAt(height)
expect(result.validators).toBeDefined()
// TODO: Check the result
expect(result).toBeDefined()
})
})

Expand All @@ -220,8 +221,8 @@ describe('PlatformAPI', () => {

describe('validatedBy', () => {
test.each([
{ blockchainID: GenesisJUNEChain.id },
{ blockchainID: '2k1EyxAV5XYPxnsuPVrKyquUTLC3EMA1c5AhM7r8sRy1Kg7Zje' }
{ blockchainID: PROVIDER.juneChain.id },
{ blockchainID: '3pW4zxtzuMAWLA6rdttWDqkVMtGRTqohthSDW962k8GTNyKXj' }
])('Valid blockchainID: $blockchainID', async ({ blockchainID }) => {
const result = await PROVIDER.platformApi.validatedBy(blockchainID)
expect(result.supernetID).toBeDefined()
Expand All @@ -231,7 +232,7 @@ describe('PlatformAPI', () => {
describe('validates', () => {
test.each([
{ supernetID: PROVIDER.mcn.primary.id },
{ supernetID: 'ZLfejkjx2AwkaNbGC7oQxX3gE6G1YLs4FzMimQEG6Us2b7UpW' }
{ supernetID: 'qyieai1WRqtxqKwn8CUUAfgXfu6rQbHJhiiLE6DpCWHXtHTGG' }
])('Valid supernetID: $supernetID', async ({ supernetID }) => {
const result = await PROVIDER.platformApi.validates(supernetID)
expect(result.blockchainIDs).toBeDefined()
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/constants.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as dotenv from 'dotenv'
import { GenesisNetwork, MCNAccount, MCNProvider, MCNWallet } from '../../src'
import { MCNAccount, MCNProvider, MCNWallet, SocotraNetwork } from '../../src'
dotenv.config()

export const PROVIDER: MCNProvider = new MCNProvider(GenesisNetwork)
export const PROVIDER: MCNProvider = new MCNProvider(SocotraNetwork)
const WALLET = MCNWallet.recover(process.env.MNEMONIC ?? '', PROVIDER.mcn.hrp)
export const ACCOUNT: MCNAccount = new MCNAccount(PROVIDER, WALLET)

Expand Down
31 changes: 16 additions & 15 deletions tests/e2e/wallet/cross.test.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,30 @@
import {
AccountError,
CrossOperation,
GenesisEUROC1Chain,
GenesisJUNEChain,
GenesisJVMChain,
GenesisPlatformChain,
InputError,
NetworkOperationRange,
NetworkOperationType,
SocotraEUR1Chain,
SocotraJUNEChain,
SocotraJVMChain,
SocotraPlatformChain,
type ExecutableOperation
} from '../../../src'
import { ACCOUNT, DEFAULT_TIMEOUT, DONE_STATUS, EXCESSIVE_AMOUNT } from '../constants'

describe('Cross operations', () => {
const juneChain = GenesisJUNEChain
const euroChain = GenesisEUROC1Chain
const platformChain = GenesisPlatformChain
const jvmChain = GenesisJVMChain
const juneChain = SocotraJUNEChain
const euroChain = SocotraEUR1Chain
const platformChain = SocotraPlatformChain
const jvmChain = SocotraJVMChain
const euroAddress = '0x3000000000000000000000000000000000000000'

describe('Instantiation', () => {
test.each([
{
source: juneChain,
destination: euroChain,
assetId: '0x3300000000000000000000000000000000000000',
assetId: euroAddress,
symbol: 'EUROC.e',
value: BigInt(1_000)
},
Expand Down Expand Up @@ -58,21 +59,21 @@ describe('Cross operations', () => {
{
source: juneChain,
destination: euroChain,
assetId: '0x3300000000000000000000000000000000000000',
assetId: euroAddress,
symbol: 'EUROC.e',
value: EXCESSIVE_AMOUNT
},
{
source: juneChain,
destination: euroChain,
assetId: '0x3300000000000000000000000000000000000000',
assetId: euroAddress,
symbol: 'EUROC.e',
value: BigInt(0)
},
{
source: juneChain,
destination: euroChain,
assetId: '0x3300000000000000000000000000000000000000',
assetId: euroAddress,
symbol: 'EUROC.e',
value: BigInt(-1_000)
}
Expand All @@ -96,7 +97,7 @@ describe('Cross operations', () => {
{
source: juneChain,
destination: euroChain,
assetId: '0x3300000000000000000000000000000000000000',
assetId: euroAddress,
symbol: 'EUROC.e',
value: BigInt(1_000)
},
Expand Down Expand Up @@ -167,15 +168,15 @@ describe('Cross operations', () => {
{
source: juneChain,
destination: euroChain,
assetId: '0x3300000000000000000000000000000000000000',
assetId: euroAddress,
symbol: 'EUROC.e',
value: BigInt(-1),
expectedError: InputError
},
{
source: juneChain,
destination: euroChain,
assetId: '0x3300000000000000000000000000000000000000',
assetId: euroAddress,
symbol: 'EUROC.e',
value: EXCESSIVE_AMOUNT,
expectedError: AccountError
Expand Down
15 changes: 8 additions & 7 deletions tests/e2e/wallet/send.test.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import {
AccountError,
GenesisEUROC1Chain,
GenesisJUNEChain,
GenesisJVMChain,
SendOperation,
SocotraEUR1Chain,
SocotraJUNEChain,
SocotraJVMChain,
type ExecutableOperation
} from '../../../src'
import { ACCOUNT, DEFAULT_TIMEOUT, DONE_STATUS, EXCESSIVE_AMOUNT } from '../constants'

describe('Send operations', () => {
const juneChain = GenesisJUNEChain
const euroChain = GenesisEUROC1Chain
const jvmChain = GenesisJVMChain
const juneChain = SocotraJUNEChain
const euroChain = SocotraEUR1Chain
const jvmChain = SocotraJVMChain
const euroAddress = '0x3000000000000000000000000000000000000000'

describe('EVM send', () => {
describe('Valid execute', () => {
Expand All @@ -25,7 +26,7 @@ describe('Send operations', () => {
},
{
chain: juneChain,
assetId: '0x2d00000000000000000000000000000000000000',
assetId: euroAddress,
symbol: 'ETH.e',
value: BigInt(1),
recipient: '0x3c647d88Bc92766075feA7A965CA599CAAB2FD26'
Expand Down
8 changes: 5 additions & 3 deletions tests/e2e/wallet/stake.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,18 @@ import { ACCOUNT, DEFAULT_TIMEOUT, DONE_STATUS, EXCESSIVE_AMOUNT, PROVIDER } fro

const chainAccount: ChainAccount = ACCOUNT.getAccount(PROVIDER.platformChain.id)
// for now we take this nodeID. maybe in the future we can select the node Id with a function
const validNodeId = 'NodeID-P6qNB7Zk2tUirf9TvBiXxiCHxa5Hzq6sL'
const validNodeId = 'NodeID-4JfgcoMWBpxCQL5VmyQ1f6L36mUbLLBga'
const ONE_DAY: bigint = BigInt(86_400)
let currentTime: bigint = TimeUtils.now() + BigInt(30)
let tomorrow: bigint = currentTime + ONE_DAY
let twoWeeks: bigint = currentTime + BigInt(14) * ONE_DAY

describe('Staking operations', (): void => {
beforeAll(async () => {
// TODO create time provider utils to manage those tests
currentTime = TimeUtils.now() + BigInt(30)
tomorrow = currentTime + ONE_DAY
twoWeeks = currentTime + BigInt(14) * ONE_DAY + BigInt(30)
})

test.todo('operations instantiations')
Expand All @@ -29,10 +31,10 @@ describe('Staking operations', (): void => {
test.each([
{
nodeId: validNodeId,
amount: BigInt(10_000_000),
amount: BigInt(100_000_000), // 0.1 JUNE
expectedStatus: DONE_STATUS,
startTime: currentTime,
endTime: tomorrow
endTime: twoWeeks
}
])(
'$#) $amount tokens to delegate node id: $nodeId from $startTime to $endTime',
Expand Down
8 changes: 4 additions & 4 deletions tests/e2e/wallet/wrap.test.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import {
AccountError,
GenesisJUNEChain,
GenesisWJUNEAsset,
NetworkOperationRange,
NetworkOperationType,
SocotraJUNEChain,
SocotraWJUNEAsset,
UnwrapOperation,
WrapOperation,
type ExecutableOperation
} from '../../../src'
import { ACCOUNT, DEFAULT_TIMEOUT, DONE_STATUS, EXCESSIVE_AMOUNT } from '../constants'

describe('Wrapping operations', () => {
const juneChain = GenesisJUNEChain
const wJuneAsset = GenesisWJUNEAsset
const juneChain = SocotraJUNEChain
const wJuneAsset = SocotraWJUNEAsset

describe('WrapOperation', () => {
describe('Instantiation', () => {
Expand Down
Loading

0 comments on commit 72a77a7

Please sign in to comment.