Skip to content

Commit

Permalink
test(adapter): update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
envin3 committed Nov 8, 2024
1 parent 7c1e209 commit 6732601
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 0 deletions.
32 changes: 32 additions & 0 deletions cpp/test/adapter-non-local.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -584,5 +584,37 @@ describe('Adapter EVM -> EOS testing', () => {
`0.0000 ${evmXERC20.symbol}`,
)
})

it('Should truncate the passed amount to the set precision', async () => {
const operation = evmOperationSamples.peginLargePrecision
const metadata = evmMetadataSamples.peginLargePrecision

const before = getAccountsBalances(
[user, recipient, adapter.account],
[evmXERC20],
)
const beforeAsset = Asset.from(before[recipient][evmXERC20.symbol])

await adapter.contract.actions
.settle([user, operation, metadata])
.send(active(user))

console.log(adapter.contract.bc.console)

const after = getAccountsBalances(
[user, recipient, adapter.account],
[evmXERC20],
)

const adjAmount = adjustPrecision(operation.amount, evmXERC20Precision)
const adjOperationAmount = Asset.from(`${adjAmount} ${evmXERC20.symbol}`)
expect(after[recipient][evmXERC20.symbol]).to.equal(
sum(adjOperationAmount, beforeAsset).toString(),
)

expect(after[adapter.account][evmXERC20.symbol]).to.be.equal(
`0.0000 ${evmXERC20.symbol}`,
)
})
})
})
6 changes: 6 additions & 0 deletions cpp/test/samples/evm-metadata.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions cpp/test/samples/evm-operations.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,20 @@ const evmOperationSamples = {
recipient: 'eosrecipient',
data: '12345abcdefc0de1337f',
},
peginLargePrecision: {
blockId: '9c6d1358f426fe23fc7cf0e67aa422ff27c4e5ec7899297a10f036e6cf6643da',
txId: '96d4d6885f072cb3f734d1b4add1d78d46487692cf9d912a6a91cfc6c65bc7d6',
nonce: 0,
token: '000000000000000000000000810090f35dfa6b18b5eb59d298e2a2443a2811e2',
originChainId:
'0000000000000000000000000000000000000000000000000000000000000001', // ETH chain id
destinationChainId:
'aca376f206b8fc25a6ed44dbdc66547c36c6c33e3a119ffbeaef943642f0e906', // EOS chain id
amount: '1.189215224969292133 XTST',
sender: '000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb92266',
recipient: 'eosrecipient',
data: '',
},
}

module.exports = {
Expand Down

0 comments on commit 6732601

Please sign in to comment.