Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: update msg_index by order in event and log #327

Merged
merged 19 commits into from
Sep 22, 2023
Merged
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 79 additions & 0 deletions test/unit/services/crawl-transaction/parse_transaction.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,85 @@ export default class CrawlTransactionTest {
// );
}

@Test('Mapping event and log')
public async testMappingEventToLog() {
const arrDest = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

em copy cái test khó khó như thật ấy

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added test for case authz

index: 3,
type: 'message',
attributes: [
{
key: 'action',
value: '/cosmos.staking.v1beta1.MsgDelegate',
},
{
key: 'sender',
value: 'aura1jv65s3grqf6v6jl3dp4t6c9t9rk99cd8ufn7tx',
},
{
key: 'module',
value: 'staking',
},
{
key: 'sender',
value: 'aura15x4v36r6rl73nhn9h0954mwp42sawrc25f0rnx',
},
],
};
const arrSrc: any[] = [
{
// this event is not in log (arrDest), so it doesn't has checkedIndex
type: 'message',
attributes: [
{
key: 'c2VuZGVy',
value:
'YXVyYTE1eDR2MzZyNnJsNzNuaG45aDA5NTRtd3A0MnNhd3JjMjVmMHJueA==',
},
],
},
{
checkedIndex: 3,
type: 'message',
attributes: [
{
key: 'YWN0aW9u',
value: 'L2Nvc21vcy5zdGFraW5nLnYxYmV0YTEuTXNnRGVsZWdhdGU=',
},
],
},
{
checkedIndex: 3,
type: 'message',
attributes: [
{
key: 'c2VuZGVy',
value:
'YXVyYTFqdjY1czNncnFmNnY2amwzZHA0dDZjOXQ5cms5OWNkOHVmbjd0eA==',
},
],
},
{
checkedIndex: 3,
type: 'message',
attributes: [
{
key: 'bW9kdWxl',
value: 'c3Rha2luZw==',
},
{
key: 'c2VuZGVy',
value:
'YXVyYTE1eDR2MzZyNnJsNzNuaG45aDA5NTRtd3A0MnNhd3JjMjVmMHJueA==',
},
],
},
];
this.crawlTxService?.mappingEventToLog(arrDest, arrSrc, arrDest.index);
arrSrc.forEach((item) => {
expect(item.checkedIndex).toEqual(item.msg_index);
});
}

@AfterEach()
async tearDown() {
this.crawlTxService?.getQueueManager().stopAll();
Expand Down