Skip to content

Commit

Permalink
add tests for msgDeposit
Browse files Browse the repository at this point in the history
  • Loading branch information
Z4karia authored Apr 12, 2024
1 parent 2806bdd commit 8fcb2e5
Show file tree
Hide file tree
Showing 32 changed files with 94 additions and 5 deletions.
6 changes: 1 addition & 5 deletions app/src/parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,7 @@ __Z_INLINE parser_error_t parser_formatAmountItem(uint16_t amountToken,
return parser_unexpected_field;
}

if (!parser_areEqual(amountToken + 1u, "amount")) {
return parser_unexpected_field;
}

if (!parser_areEqual(amountToken + 3u, "denom")) {
if (parser_tx_obj.tx_json.json.tokens[amountToken + 2].type != JSMN_STRING) {
return parser_unexpected_field;
}

Expand Down
89 changes: 89 additions & 0 deletions tests/testcases/thor.json
Original file line number Diff line number Diff line change
Expand Up @@ -271,4 +271,93 @@
],
"expert": true
},
{
"name": "msgDepositMultipleAmountsExpert",
"tx": {
"account_number": "588",
"chain_id": "thorchain",
"fee": {
"amount": [],
"gas": "10000000"
},
"memo": "",
"msgs": [
{
"type": "thorchain/MsgDeposit",
"value": {
"coins": [
{
"amount": "330000000",
"asset": "THOR.RUNE"
},
{
"amount": "220000000",
"asset": "BSC.USDT"
}
],
"memo": "SWAP:BNB.BNB:tbnb1qk2m905ypazwfau9cn0qnr4c4yxz63v9u9md20:",
"signer": "tthor1c648xgpter9xffhmcqvs7lzd7hxh0prgv5t5gp"
}
}
],
"sequence": "6"
},
"parsingErr": "No error",
"validationErr": "No error",
"expected": [
"0 | Chain ID : thorchain",
"1 | Account : 588",
"2 | Sequence : 6",
"3 | Type : Deposit",
"4 | Amount [1/2] : 330000000 THOR.RUNE",
"4 | Amount [2/2] : 220000000 BSC.USDT",
"5 | Memo [1/2] : SWAP:BNB.BNB:tbnb1qk2m905ypazwfau9cn0qn",
"5 | Memo [2/2] : r4c4yxz63v9u9md20:",
"6 | Sender [1/2] : tthor1c648xgpter9xffhmcqvs7lzd7hxh0prgv",
"6 | Sender [2/2] : 5t5gp",
"7 | Fee : Empty",
"8 | Gas : 10000000"
],
"expert": true
},
{
"name": "msgDepositNoMemoExpert",
"tx": {
"account_number": "588",
"chain_id": "thorchain",
"fee": {
"amount": [],
"gas": "10000000"
},
"msgs": [
{
"type": "thorchain/MsgDeposit",
"value": {
"coins": [
{
"amount": "330000000",
"asset": "THOR.RUNE"
}
],
"signer": "tthor1c648xgpter9xffhmcqvs7lzd7hxh0prgv5t5gp"
}
}
],
"sequence": "6"
},
"parsingErr": "No error",
"validationErr": "JSON Missing memo",
"expected": [
"0 | Chain ID : thorchain",
"1 | Account : 588",
"2 | Sequence : 6",
"3 | Type : Deposit",
"4 | Amount : 330000000 THOR.RUNE",
"5 | Sender [1/2] : tthor1c648xgpter9xffhmcqvs7lzd7hxh0prgv",
"5 | Sender [2/2] : 5t5gp",
"6 | Fee : Empty",
"7 | Gas : 10000000"
],
"expert": true
}
]
Binary file added tests_zemu/snapshots/s-sign_msgDeposit/00000.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests_zemu/snapshots/s-sign_msgDeposit/00001.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests_zemu/snapshots/s-sign_msgDeposit/00002.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests_zemu/snapshots/s-sign_msgDeposit/00003.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests_zemu/snapshots/s-sign_msgDeposit/00004.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests_zemu/snapshots/s-sign_msgDeposit/00005.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests_zemu/snapshots/s-sign_msgDeposit/00006.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests_zemu/snapshots/s-sign_msgDeposit/00007.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests_zemu/snapshots/sp-sign_msgDeposit/00000.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests_zemu/snapshots/sp-sign_msgDeposit/00001.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests_zemu/snapshots/sp-sign_msgDeposit/00002.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests_zemu/snapshots/sp-sign_msgDeposit/00003.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests_zemu/snapshots/sp-sign_msgDeposit/00004.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests_zemu/snapshots/sp-sign_msgDeposit/00005.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests_zemu/snapshots/sp-sign_msgDeposit/00006.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests_zemu/snapshots/sp-sign_msgDeposit/00007.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests_zemu/snapshots/st-sign_msgDeposit/00000.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests_zemu/snapshots/st-sign_msgDeposit/00001.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests_zemu/snapshots/st-sign_msgDeposit/00002.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests_zemu/snapshots/st-sign_msgDeposit/00003.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests_zemu/snapshots/st-sign_msgDeposit/00004.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests_zemu/snapshots/x-sign_msgDeposit/00000.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests_zemu/snapshots/x-sign_msgDeposit/00001.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests_zemu/snapshots/x-sign_msgDeposit/00002.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests_zemu/snapshots/x-sign_msgDeposit/00003.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tests_zemu/snapshots/x-sign_msgDeposit/00004.png
Binary file added tests_zemu/snapshots/x-sign_msgDeposit/00005.png
Binary file added tests_zemu/snapshots/x-sign_msgDeposit/00006.png
Binary file added tests_zemu/snapshots/x-sign_msgDeposit/00007.png
4 changes: 4 additions & 0 deletions tests_zemu/tests/thor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,8 @@ describe('Thor', function () {
await signAndVerifyTransaction(m, 'sign_msgSend', example_tx_str_MsgSend);
});

test.concurrent.each(DEVICE_MODELS)('sign msgDeposit normal', async function (m) {
await signAndVerifyTransaction(m, 'sign_msgDeposit', example_tx_str_MsgDeposit);
});

})

0 comments on commit 8fcb2e5

Please sign in to comment.