Skip to content

Commit

Permalink
test: update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
iosh committed Nov 9, 2024
1 parent d4e1862 commit b8d8201
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 195 deletions.
8 changes: 2 additions & 6 deletions src/actions/public/estimateFeesPerGas.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ test('default', async () => {
const { maxFeePerGas, maxPriorityFeePerGas } =
await estimateFeesPerGas(client)

expect(maxFeePerGas).toBe(
(block.baseFeePerGas! * 120n) / 100n + maxPriorityFeePerGas,
)
expect(maxFeePerGas).toBe(block.baseFeePerGas! + maxPriorityFeePerGas)
expect(maxPriorityFeePerGas).toBeDefined()
})

Expand All @@ -37,9 +35,7 @@ describe('internal_estimateFeesPerGas', () => {
block: { baseFeePerGas } as any,
request: { maxPriorityFeePerGas } as any,
})
expect(maxFeePerGas).toBe(
(baseFeePerGas * 120n) / 100n + maxPriorityFeePerGas,
)
expect(maxFeePerGas).toBe(baseFeePerGas + maxPriorityFeePerGas)
})

test('maxFeePerGas request args', async () => {
Expand Down
6 changes: 3 additions & 3 deletions src/actions/public/getAccountPendingInfo.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ test('with tx', async () => {
).toMatchInlineSnapshot(`
{
"localNonce": 0n,
"nextPendingTx": 45869683219349642423684220173494286329207765601632196501992601067641417510919n,
"nextPendingTx": 34993918322552798075736612473029692312583248690501399920505890097382783775166n,
"pendingCount": 1n,
"pendingNonce": 0n,
}
Expand All @@ -67,7 +67,7 @@ test('with tx', async () => {
).toMatchInlineSnapshot(`
{
"localNonce": 0n,
"nextPendingTx": 45869683219349642423684220173494286329207765601632196501992601067641417510919n,
"nextPendingTx": 34993918322552798075736612473029692312583248690501399920505890097382783775166n,
"pendingCount": 2n,
"pendingNonce": 0n,
}
Expand All @@ -84,7 +84,7 @@ test('with tx', async () => {
).toMatchInlineSnapshot(`
{
"localNonce": 0n,
"nextPendingTx": 45869683219349642423684220173494286329207765601632196501992601067641417510919n,
"nextPendingTx": 34993918322552798075736612473029692312583248690501399920505890097382783775166n,
"pendingCount": 3n,
"pendingNonce": 0n,
}
Expand Down
208 changes: 31 additions & 177 deletions src/actions/public/getAccountPendingTransactions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,97 +26,24 @@ afterAll(async () => {
})

test('default', async () => {
expect(
await getAccountPendingTransactions(client, {
address: sourceAccount.address,
}),
).toMatchInlineSnapshot(`
{
"firstTxStatus": "ready",
"pendingCount": 2n,
"pendingTransactions": [
{
"blockHash": null,
"chainId": 201029,
"contractCreated": null,
"data": "0x",
"epochHeight": 0n,
"from": "NET201029:TYPE.USER:AAM085E78N2F8HY6C02U5TZ7VBJ6XREEF6A6STZJ3X",
"gas": 21000n,
"gasPrice": 1200000000n,
"hash": "0xd96c3e5b62e7396971c9e88b52aee75962f485a795d250b65dcfa211d4fec1b5",
"nonce": 0,
"r": "0x3c9e64f061a7e902ba8fc8d68d71a3122cac15d32982792e6c6ade300059587f",
"s": "0x7ca8d1618c58bb0bbf94846e442891ac00d717121f30393470770511db8d7e3a",
"status": null,
"storageLimit": 0n,
"to": "NET201029:TYPE.USER:AAM085E78N2F8HY6C02U5TZ7VBJ6XREEF6A6STZJ3X",
"transactionIndex": null,
"type": "legacy",
"v": 1n,
"value": 10000000000000000n,
},
{
"blockHash": null,
"chainId": 201029,
"contractCreated": null,
"data": "0x",
"epochHeight": 0n,
"from": "NET201029:TYPE.USER:AAM085E78N2F8HY6C02U5TZ7VBJ6XREEF6A6STZJ3X",
"gas": 21000n,
"gasPrice": 1200000000n,
"hash": "0x4b05eec3ebaa8ad200bded2d2d68754fa7e6c0a568bd91050b35236e2a97d76d",
"nonce": 1,
"r": "0x6cefd6d8bf9d2bc760ade644d4fa57a8105c2d5100e83c5aa240896de7e67365",
"s": "0x342d80c056de4de57b033700c749f9dadfc407b063441b58f9b6eea02bb8e3d9",
"status": null,
"storageLimit": 0n,
"to": "NET201029:TYPE.USER:AAM085E78N2F8HY6C02U5TZ7VBJ6XREEF6A6STZJ3X",
"transactionIndex": null,
"type": "legacy",
"v": 0n,
"value": 10000000000000000n,
},
],
}
`)
const pendingTransactions = await getAccountPendingTransactions(client, {
address: sourceAccount.address,
})

expect(pendingTransactions.pendingCount).toBe(2n)
expect(pendingTransactions.firstTxStatus).toBe('ready')
expect(pendingTransactions.pendingTransactions.length).toBe(2)
})

test('with nonce', async () => {
expect(
await getAccountPendingTransactions(client, {
address: sourceAccount.address,
nonce: 1,
}),
).toMatchInlineSnapshot(`
{
"firstTxStatus": "ready",
"pendingCount": 1n,
"pendingTransactions": [
{
"blockHash": null,
"chainId": 201029,
"contractCreated": null,
"data": "0x",
"epochHeight": 0n,
"from": "NET201029:TYPE.USER:AAM085E78N2F8HY6C02U5TZ7VBJ6XREEF6A6STZJ3X",
"gas": 21000n,
"gasPrice": 1200000000n,
"hash": "0x4b05eec3ebaa8ad200bded2d2d68754fa7e6c0a568bd91050b35236e2a97d76d",
"nonce": 1,
"r": "0x6cefd6d8bf9d2bc760ade644d4fa57a8105c2d5100e83c5aa240896de7e67365",
"s": "0x342d80c056de4de57b033700c749f9dadfc407b063441b58f9b6eea02bb8e3d9",
"status": null,
"storageLimit": 0n,
"to": "NET201029:TYPE.USER:AAM085E78N2F8HY6C02U5TZ7VBJ6XREEF6A6STZJ3X",
"transactionIndex": null,
"type": "legacy",
"v": 0n,
"value": 10000000000000000n,
},
],
}
`)
const pendingTransactions = await getAccountPendingTransactions(client, {
address: sourceAccount.address,
nonce: 1,
})

expect(pendingTransactions.pendingCount).toBe(1n)
expect(pendingTransactions.firstTxStatus).toBe('ready')
expect(pendingTransactions.pendingTransactions.length).toBe(1)

expect(
await getAccountPendingTransactions(client, {
Expand All @@ -133,94 +60,21 @@ test('with nonce', async () => {
})

test('with limit', async () => {
expect(
await getAccountPendingTransactions(client, {
address: sourceAccount.address,
limit: 1,
}),
).toMatchInlineSnapshot(`
{
"firstTxStatus": "ready",
"pendingCount": 2n,
"pendingTransactions": [
{
"blockHash": null,
"chainId": 201029,
"contractCreated": null,
"data": "0x",
"epochHeight": 0n,
"from": "NET201029:TYPE.USER:AAM085E78N2F8HY6C02U5TZ7VBJ6XREEF6A6STZJ3X",
"gas": 21000n,
"gasPrice": 1200000000n,
"hash": "0xd96c3e5b62e7396971c9e88b52aee75962f485a795d250b65dcfa211d4fec1b5",
"nonce": 0,
"r": "0x3c9e64f061a7e902ba8fc8d68d71a3122cac15d32982792e6c6ade300059587f",
"s": "0x7ca8d1618c58bb0bbf94846e442891ac00d717121f30393470770511db8d7e3a",
"status": null,
"storageLimit": 0n,
"to": "NET201029:TYPE.USER:AAM085E78N2F8HY6C02U5TZ7VBJ6XREEF6A6STZJ3X",
"transactionIndex": null,
"type": "legacy",
"v": 1n,
"value": 10000000000000000n,
},
],
}
`)
const pendingTransactions = await getAccountPendingTransactions(client, {
address: sourceAccount.address,
limit: 1,
})

expect(
await getAccountPendingTransactions(client, {
address: sourceAccount.address,
limit: 999,
}),
).toMatchInlineSnapshot(`
{
"firstTxStatus": "ready",
"pendingCount": 2n,
"pendingTransactions": [
{
"blockHash": null,
"chainId": 201029,
"contractCreated": null,
"data": "0x",
"epochHeight": 0n,
"from": "NET201029:TYPE.USER:AAM085E78N2F8HY6C02U5TZ7VBJ6XREEF6A6STZJ3X",
"gas": 21000n,
"gasPrice": 1200000000n,
"hash": "0xd96c3e5b62e7396971c9e88b52aee75962f485a795d250b65dcfa211d4fec1b5",
"nonce": 0,
"r": "0x3c9e64f061a7e902ba8fc8d68d71a3122cac15d32982792e6c6ade300059587f",
"s": "0x7ca8d1618c58bb0bbf94846e442891ac00d717121f30393470770511db8d7e3a",
"status": null,
"storageLimit": 0n,
"to": "NET201029:TYPE.USER:AAM085E78N2F8HY6C02U5TZ7VBJ6XREEF6A6STZJ3X",
"transactionIndex": null,
"type": "legacy",
"v": 1n,
"value": 10000000000000000n,
},
{
"blockHash": null,
"chainId": 201029,
"contractCreated": null,
"data": "0x",
"epochHeight": 0n,
"from": "NET201029:TYPE.USER:AAM085E78N2F8HY6C02U5TZ7VBJ6XREEF6A6STZJ3X",
"gas": 21000n,
"gasPrice": 1200000000n,
"hash": "0x4b05eec3ebaa8ad200bded2d2d68754fa7e6c0a568bd91050b35236e2a97d76d",
"nonce": 1,
"r": "0x6cefd6d8bf9d2bc760ade644d4fa57a8105c2d5100e83c5aa240896de7e67365",
"s": "0x342d80c056de4de57b033700c749f9dadfc407b063441b58f9b6eea02bb8e3d9",
"status": null,
"storageLimit": 0n,
"to": "NET201029:TYPE.USER:AAM085E78N2F8HY6C02U5TZ7VBJ6XREEF6A6STZJ3X",
"transactionIndex": null,
"type": "legacy",
"v": 0n,
"value": 10000000000000000n,
},
],
}
`)
expect(pendingTransactions.pendingCount).toBe(2n)
expect(pendingTransactions.firstTxStatus).toBe('ready')
expect(pendingTransactions.pendingTransactions.length).toBe(1)

const pendingTransactions2 = await getAccountPendingTransactions(client, {
address: sourceAccount.address,
limit: 999,
})

expect(pendingTransactions2.pendingCount).toBe(2n)
expect(pendingTransactions2.firstTxStatus).toBe('ready')
expect(pendingTransactions2.pendingTransactions.length).toBe(2)
})
2 changes: 1 addition & 1 deletion src/actions/public/getBalance.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ test('gets balance when transaction', async () => {

expect(
await getBalance(client, { address: sourceAccount.address }),
).toMatchInlineSnapshot('9989999974800000000000n')
).toMatchInlineSnapshot('9989999979000000000000n')

expect(
await getBalance(client, { address: targetAccount.address }),
Expand Down
6 changes: 3 additions & 3 deletions src/actions/public/getTransaction.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,14 @@ test('default', async () => {
`"NET201029:TYPE.USER:AAM085E78N2F8HY6C02U5TZ7VBJ6XREEF6A6STZJ3X"`,
)
expect(tx.hash).toMatchInlineSnapshot(
`"0x2e277f2031cb9dcb57d174b99e1f33f4f0141f5bd2e6ddbfa9675ddbedff164b"`,
`"0x2544af3be3c64246d01e2c38372f34135a55baefa90477d5e70ab2296065416e"`,
)
expect(tx.nonce).toMatchInlineSnapshot('0')
expect(tx.r).toMatchInlineSnapshot(
`"0xcf3f05859dd82398bec754f12f8ba4bf60cf9d98ed6d2a1397a919fd5e69ccc2"`,
`"0xa3df516d1c0134073e2247d0e4004bcf9562f4cd0cba705ca04209d816c5b47c"`,
)
expect(tx.s).toMatchInlineSnapshot(
`"0x491b9484ef00f5e7f4b2e7bd687ccbba5d3b2c7b3bc531fb50468dae9f4e57d2"`,
`"0x53ad709a9e8a35428c85de544d964bef07f15c20f0516c523e8aa5565eb27058"`,
)
})

Expand Down
2 changes: 1 addition & 1 deletion src/actions/public/getTransactionReceipt.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ test('default', async () => {
)

expect(receipt.transactionHash).toMatchInlineSnapshot(
`"0x2e277f2031cb9dcb57d174b99e1f33f4f0141f5bd2e6ddbfa9675ddbedff164b"`,
`"0x2544af3be3c64246d01e2c38372f34135a55baefa90477d5e70ab2296065416e"`,
)

expect(receipt.epochNumber).toMatchInlineSnapshot('1n')
Expand Down
2 changes: 1 addition & 1 deletion src/actions/wallet/prepareTransactionRequest.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ test('default', async () => {
"epochHeight": 0n,
"from": "net201029:aam085e78n2f8hy6c02u5tz7vbj6xreef6a6stzj3x",
"gas": 21000n,
"gasPrice": 1200000000n,
"gasPrice": 1000000000n,
"storageLimit": 0n,
"to": "net201029:aam085e78n2f8hy6c02u5tz7vbj6xreef6a6stzj3x",
"type": "legacy",
Expand Down
1 change: 0 additions & 1 deletion src/clients/createWalletClient.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,6 @@ describe('args: transport', () => {
"getConfirmationRiskByHash": [Function],
"getContractEvents": [Function],
"getCurrentSyncPhase": [Function],
"getDepositList": [Function],
"getEpochNumber": [Function],
"getEpochReceipts": [Function],
Expand Down
4 changes: 2 additions & 2 deletions src/utils/abi/encodeAbiParameters.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ describe('static', () => {
`
[AbiEncodingBytesSizeMismatchError: Size of bytes "0x0000000000000000000000000000000000000000000000000000000000000000000000000123456789abcdef" (bytes44) does not match expected size (bytes8).
Version: [email protected].32]
Version: [email protected].43]
`,
)
})
Expand Down Expand Up @@ -386,7 +386,7 @@ describe('static', () => {
`
[AbiEncodingBytesSizeMismatchError: Size of bytes "0x000000000000000000000000000000000000000000000000000000000000000420" (bytes33) does not match expected size (bytes16).
Version: [email protected].32]
Version: [email protected].43]
`,
)
})
Expand Down

0 comments on commit b8d8201

Please sign in to comment.