Skip to content

Commit

Permalink
Fix the parsing of precompile omnibridge event data (#3259)
Browse files Browse the repository at this point in the history
* fix event data parsing

* fix one more

* fix typo

* adding event_data type

* Un-comment
  • Loading branch information
0xverin authored Feb 17, 2025
1 parent 7ac8200 commit 7c08d8f
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions parachain/ts-tests/integration-tests/precompile-contract.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,17 +194,26 @@ describeLitentry('Test Parachain Precompile Contract', ``, (context) => {
const events = (await eventsPromise).map(({ event }) => event);

expect(events.length).to.eq(1);
const event_data = events[0].toHuman().data! as Array<string>;
console.log(`Print Event data: ${event_data}`);
const event_data = events[0].toHuman().data! as {
sourceAccount: string;
nonce: number;
asset: string;
resourceId: string;
destChain: {
Ethereum: string;
};
destAccount: string;
amount: string;
};
console.log(`Print Event data: ${JSON.stringify(event_data)}`);

// PaidIn(source_account, nonce, asset, resource_id, dest_chain, dest_account, amount)
// TODO: This is not working, objective undefined can not be compared
// expect(JSON.stringify(event_data[4])).to.eq(JSON.stringify({Ethereum:0}));
// expect(event_data[5]).to.eq(dest_address);
expect(event_data.destChain).to.deep.equal({ Ethereum: '0' });
expect(event_data.destAccount).to.eq(dest_address);

// 0.01 - 0.001 = 0.009
// const expectedBalance = bn1e18.div(bn100).sub(bn1e18.div(bn1000));
// expect(event_data[6].toString().replace(/,/g, '')).to.eq(expectedBalance.toString());
const expectedBalance = bn1e18.div(bn100).sub(bn1e18.div(bn1000));
expect(event_data.amount.replace(/,/g, '')).to.eq(expectedBalance.toString());

console.timeEnd('Test precompile omni bridge contract');
});
Expand Down

0 comments on commit 7c08d8f

Please sign in to comment.