1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-26 00:08:10 +00:00

chore(solana): add sign_tx tests

This commit is contained in:
gabrielkerekes 2023-10-18 12:07:14 +02:00 committed by matejcik
parent 68c0e6c43e
commit e53121b3c4
10 changed files with 2920 additions and 0 deletions

View File

@ -0,0 +1,94 @@
{
"setup": {
"mnemonic": "all all all all all all all all all all all all",
"passphrase": ""
},
"tests": [
{
"description": "Create Associated Token Account",
"parameters": {
"address": "m/44'/501'/0'/0'",
"construct": {
"version": null,
"header": {
"signers": 1,
"readonly_signers": 0,
"readonly_non_signers": 4
},
"accounts": [
"14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS",
"FUqrjRRtF1LiptdFqaFxipE8R3YfCE4k56xwm5n1piqX",
"11111111111111111111111111111111",
"6YuhWADZyAAxAaVKPm1G5N51RvDBXsnWo4SfsJ47wSoK",
"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL",
"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
],
"blockhash": "2p4rYZAaFfV5Uk5ugdG5KPNty9Uda9B3b4gWB8qnNqak",
"instructions": [
{
"program_index": 4,
"accounts": {
"funding_account": 0,
"associated_token_account": 1,
"wallet_address": 0,
"token_mint": 3,
"system_program": 2,
"spl_token": 5
},
"data": {
"instruction_id": null
}
}
],
"luts": []
}
},
"result": {
"expected_signature": "629daa88d10bca2315fe4176c323197a22c821026f7f6019cadbcf2769c5bb38ceef7652b5cba7e246a51f131f14fa8d776df63c50a1c4a09a3cf0bf2d446201"
}
},
{
"description": "Create Associated Token Account Idempotent",
"parameters": {
"address": "m/44'/501'/0'/0'",
"construct": {
"version": null,
"header": {
"signers": 1,
"readonly_signers": 0,
"readonly_non_signers": 4
},
"accounts": [
"14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS",
"FUqrjRRtF1LiptdFqaFxipE8R3YfCE4k56xwm5n1piqX",
"11111111111111111111111111111111",
"6YuhWADZyAAxAaVKPm1G5N51RvDBXsnWo4SfsJ47wSoK",
"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL",
"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
],
"blockhash": "2p4rYZAaFfV5Uk5ugdG5KPNty9Uda9B3b4gWB8qnNqak",
"instructions": [
{
"program_index": 4,
"accounts": {
"funding_account": 0,
"associated_token_account": 1,
"wallet_addr": 0,
"token_mint": 3,
"system_program": 2,
"spl_token": 5
},
"data": {
"instruction_id": 1
}
}
],
"luts": []
}
},
"result": {
"expected_signature": "c7b7dc9afab413788fa185b85cbf72a90b6f12de583a478a531eaa2f7d13f6cbeae97b539c6859f2c954a9d92fbce8be12b0fe1a5a53df367e715b9793f20301"
}
}
]
}

View File

@ -0,0 +1,70 @@
{
"setup": {
"mnemonic": "all all all all all all all all all all all all",
"passphrase": ""
},
"tests": [
{
"description": "Transfer With Compute Budget",
"parameters": {
"address": "m/44'/501'/0'/0'",
"construct": {
"version": null,
"header": {
"signers": 1,
"readonly_signers": 0,
"readonly_non_signers": 2
},
"accounts": [
"14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS",
"ETxHeBBcuw9Yu4dGuP3oXrD12V5RECvmi8ogQ9PkjyVF",
"11111111111111111111111111111111",
"ComputeBudget111111111111111111111111111111"
],
"blockhash": "2p4rYZAaFfV5Uk5ugdG5KPNty9Uda9B3b4gWB8qnNqak",
"instructions": [
{
"program_index": 3,
"accounts": {},
"data": {
"instruction_id": 1,
"bytes": 2048
}
},
{
"program_index": 3,
"accounts": {},
"data": {
"instruction_id": 2,
"units": 200000
}
},
{
"program_index": 3,
"accounts": {},
"data": {
"instruction_id": 3,
"lamports": 8000
}
},
{
"program_index": 2,
"accounts": {
"funding_account": 0,
"recipient_account": 1
},
"data": {
"instruction_id": 2,
"lamports": 20000000
}
}
],
"luts": []
}
},
"result": {
"expected_signature": "682ba0889bcf9061ce0560fb7f300bfce25ff8ecdc65f1904a3fced1895de5145cf3c73352a811021d930bd224d4789b3c263acc1f1ae0fb48959d8332cc1702"
}
}
]
}

View File

@ -0,0 +1,78 @@
{
"setup": {
"mnemonic": "all all all all all all all all all all all all",
"passphrase": ""
},
"tests": [
{
"description": "Memo",
"parameters": {
"address": "m/44'/501'/0'/0'",
"construct": {
"version": null,
"header": {
"signers": 1,
"readonly_signers": 0,
"readonly_non_signers": 1
},
"accounts": [
"14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS",
"MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"
],
"blockhash": "2p4rYZAaFfV5Uk5ugdG5KPNty9Uda9B3b4gWB8qnNqak",
"instructions": [
{
"program_index": 1,
"accounts": {
"signer_accounts": 0
},
"data": {
"instruction_id": null,
"memo": "Hello World"
}
}
],
"luts": []
}
},
"result": {
"expected_signature": "0a69b5df79ea6dc007fea6d9be72a94bb19dd3f957c7634737c33452b2539f870b251cb88ef639b4f5f2720c5de1a6bedf5f9b88b5ee0fa0a9ad87634f121909"
}
},
{
"description": "Memo Legacy",
"parameters": {
"address": "m/44'/501'/0'/0'",
"construct": {
"version": null,
"header": {
"signers": 1,
"readonly_signers": 0,
"readonly_non_signers": 1
},
"accounts": [
"14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS",
"Memo1UhkJRfHyvLMcVucJwxXeuD728EqVDDwQDxFMNo"
],
"blockhash": "2p4rYZAaFfV5Uk5ugdG5KPNty9Uda9B3b4gWB8qnNqak",
"instructions": [
{
"program_index": 1,
"accounts": {
"signer_accounts": 0
},
"data": {
"instruction_id": null,
"memo": "Hello Legacy World"
}
}
],
"luts": []
}
},
"result": {
"expected_signature": "d52b675ca8a81bc9d3dd87eec309589a32645221fbab8792d5b3bf647528711321fdba67dd8af1276d62b201a5bb12d8b1a870e65341989708ccb25ef7155f08"
}
}
]
}

View File

@ -0,0 +1,707 @@
{
"setup": {
"mnemonic": "all all all all all all all all all all all all",
"passphrase": ""
},
"tests": [
{
"description": "Initialize Stake Account",
"parameters": {
"address": "m/44'/501'/0'/0'",
"construct": {
"version": null,
"header": {
"signers": 1,
"readonly_signers": 0,
"readonly_non_signers": 2
},
"accounts": [
"14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS",
"ATFXMD5cYiw9yHkvexgx3nf9LNSouEViB5BZBsgwunAv",
"Stake11111111111111111111111111111111111111",
"SysvarRent111111111111111111111111111111111"
],
"blockhash": "2p4rYZAaFfV5Uk5ugdG5KPNty9Uda9B3b4gWB8qnNqak",
"instructions": [
{
"program_index": 2,
"accounts": {
"uninitialized_stake_account": 1,
"rent_sysvar": 3
},
"data": {
"instruction_id": 0,
"staker": "14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS",
"withdrawer": "14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS",
"unix_timestamp": 20,
"epoch": 330,
"custodian": "14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS"
}
}
],
"luts": []
}
},
"result": {
"expected_signature": "196037eae9f57396938a8c673d255a8f34f1d79200fb439a1bcc551484b0a79716e8db42af041f23207f9e9e7603e567ba8fb9b6ffa4f20dad64e1277453530d"
}
},
{
"description": "Authorize",
"parameters": {
"address": "m/44'/501'/0'/0'",
"construct": {
"version": null,
"header": {
"signers": 1,
"readonly_signers": 0,
"readonly_non_signers": 1
},
"accounts": [
"14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS",
"ATFXMD5cYiw9yHkvexgx3nf9LNSouEViB5BZBsgwunAv",
"SysvarC1ock11111111111111111111111111111111",
"Stake11111111111111111111111111111111111111"
],
"blockhash": "2p4rYZAaFfV5Uk5ugdG5KPNty9Uda9B3b4gWB8qnNqak",
"instructions": [
{
"program_index": 3,
"accounts": {
"stake_account": 1,
"clock_sysvar": 2,
"stake_or_withdraw_authority": 0,
"lockup_authority": null
},
"data": {
"instruction_id": 1,
"pubkey": "ETxHeBBcuw9Yu4dGuP3oXrD12V5RECvmi8ogQ9PkjyVF",
"stake_authorize": 0
}
}
],
"luts": []
}
},
"result": {
"expected_signature": "e1c3a670771b50cb1a503ec46fd5674191753eaeb76c6c38a84417123887374e5873c0d27a0e3bf26b745a591ca540dba79113856441e7f606683aecba5cfa00"
}
},
{
"description": "Delegate",
"parameters": {
"address": "m/44'/501'/0'/0'",
"construct": {
"version": null,
"header": {
"signers": 1,
"readonly_signers": 0,
"readonly_non_signers": 5
},
"accounts": [
"14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS",
"ETxHeBBcuw9Yu4dGuP3oXrD12V5RECvmi8ogQ9PkjyVF",
"Stake11111111111111111111111111111111111111",
"StakeConfig11111111111111111111111111111111",
"SysvarC1ock11111111111111111111111111111111",
"SysvarStakeHistory1111111111111111111111111"
],
"blockhash": "2p4rYZAaFfV5Uk5ugdG5KPNty9Uda9B3b4gWB8qnNqak",
"instructions": [
{
"program_index": 2,
"accounts": {
"initialized_stake_account": 0,
"vote_account": 1,
"clock_sysvar": 4,
"stake_history_sysvar": 5,
"config_account": 3,
"stake_authority": 0
},
"data": {
"instruction_id": 2
}
}
],
"luts": []
}
},
"result": {
"expected_signature": "05d5bbece41d3ff7b330e17112a1249f2dee18ce07df8350ca904e64f9f2bab8b3590b91390f9cb773b9b53262663261d7ea734ef688c1c5fcfc6712310b7000"
}
},
{
"description": "Split",
"parameters": {
"address": "m/44'/501'/0'/0'",
"construct": {
"version": null,
"header": {
"signers": 2,
"readonly_signers": 0,
"readonly_non_signers": 2
},
"accounts": [
"14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS",
"ETxHeBBcuw9Yu4dGuP3oXrD12V5RECvmi8ogQ9PkjyVF",
"11111111111111111111111111111111",
"Stake11111111111111111111111111111111111111"
],
"blockhash": "2p4rYZAaFfV5Uk5ugdG5KPNty9Uda9B3b4gWB8qnNqak",
"instructions": [
{
"program_index": 2,
"accounts": {
"funding_account": 0,
"new_account": 1
},
"data": {
"instruction_id": 0,
"lamports": 0,
"space": 200,
"owner": "Stake11111111111111111111111111111111111111"
}
},
{
"program_index": 3,
"accounts": {
"stake_account": 0,
"uninitialized_stake_account": 1,
"stake_authority": 0
},
"data": {
"instruction_id": 3,
"lamports": 1000000
}
}
],
"luts": []
}
},
"result": {
"expected_signature": "999ba80a6183a2c99b43880190572e457a0398eb8acfa806d2c284cf2ebf9a0878239e8d1e62ac061a568db866424ccc0175c075536e325cb1f14968c0fbdc05"
}
},
{
"description": "Withdraw",
"parameters": {
"address": "m/44'/501'/0'/0'",
"construct": {
"version": null,
"header": {
"signers": 1,
"readonly_signers": 0,
"readonly_non_signers": 3
},
"accounts": [
"14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS",
"ATFXMD5cYiw9yHkvexgx3nf9LNSouEViB5BZBsgwunAv",
"Stake11111111111111111111111111111111111111",
"SysvarC1ock11111111111111111111111111111111",
"SysvarStakeHistory1111111111111111111111111"
],
"blockhash": "2p4rYZAaFfV5Uk5ugdG5KPNty9Uda9B3b4gWB8qnNqak",
"instructions": [
{
"program_index": 2,
"accounts": {
"stake_account": 1,
"recipient_account": 0,
"clock_sysvar": 3,
"stake_history_sysvar": 4,
"withdrawal_authority": 0,
"lockup_authority": 0
},
"data": {
"instruction_id": 4,
"lamports": 1000000
}
}
],
"luts": []
}
},
"result": {
"expected_signature": "2da1355daca8802daddb33bd79767ca7c4c4f3e79b4949cde10559a1836acbbd409f2227040d6b502d84292e91910ad0f12dc8a151b42e39b130a1dcd165860a"
}
},
{
"description": "Deactivate",
"parameters": {
"address": "m/44'/501'/0'/0'",
"construct": {
"version": null,
"header": {
"signers": 1,
"readonly_signers": 0,
"readonly_non_signers": 2
},
"accounts": [
"14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS",
"ATFXMD5cYiw9yHkvexgx3nf9LNSouEViB5BZBsgwunAv",
"Stake11111111111111111111111111111111111111",
"SysvarC1ock11111111111111111111111111111111"
],
"blockhash": "2p4rYZAaFfV5Uk5ugdG5KPNty9Uda9B3b4gWB8qnNqak",
"instructions": [
{
"program_index": 2,
"accounts": {
"delegated_stake_account": 1,
"clock_sysvar": 3,
"stake_authority": 0
},
"data": {
"instruction_id": 5
}
}
],
"luts": []
}
},
"result": {
"expected_signature": "6320fa5c4ced21216459f85cc180d9bb69b9f335ba6e9c71ea0482184b41020c0145f72cb0306e7f33967be8828cf4bcbfd960381e87ff0871bf1e4688bef505"
}
},
{
"description": "Set Lockup - with epoch only",
"parameters": {
"address": "m/44'/501'/0'/0'",
"construct": {
"version": null,
"header": {
"signers": 1,
"readonly_signers": 0,
"readonly_non_signers": 1
},
"accounts": [
"14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS",
"ATFXMD5cYiw9yHkvexgx3nf9LNSouEViB5BZBsgwunAv",
"Stake11111111111111111111111111111111111111"
],
"blockhash": "6Tq9obRZkiwPGQv7bX8FbMNHFBVKCXsWd5MJqSWw884Z",
"instructions": [
{
"program_index": 2,
"accounts": {
"initialized_stake_account": 1,
"lockup_or_withdraw_authority": 0
},
"data": {
"instruction_id": 6,
"unix_timestamp": {
"is_included": 0
},
"epoch": {
"is_included": 1,
"value": 20
},
"custodian": {
"is_included": 0
}
}
}
],
"luts": []
}
},
"result": {
"expected_signature": "6b21c7f625ff58ab64d9f3c54169565a1960d1612b2d5d9f51db1e17a23f3ec76955aac25fce636302c0b8db61c932e80d4031fd019a89aa6ad10c59d8a0f00b"
}
},
{
"description": "Set Lockup - with all params set",
"parameters": {
"address": "m/44'/501'/0'/0'",
"construct": {
"version": null,
"header": {
"signers": 1,
"readonly_signers": 0,
"readonly_non_signers": 1
},
"accounts": [
"14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS",
"ATFXMD5cYiw9yHkvexgx3nf9LNSouEViB5BZBsgwunAv",
"Stake11111111111111111111111111111111111111"
],
"blockhash": "ENP1bFTWGR7GiPcPg7TB9ekX82xaham8aFkB7vQeoNaZ",
"instructions": [
{
"program_index": 2,
"accounts": {
"initialized_stake_account": 1,
"lockup_or_withdraw_authority": 0
},
"data": {
"instruction_id": 6,
"unix_timestamp": {
"is_included": 1,
"value": 482196050
},
"epoch": {
"is_included": 1,
"value": 20
},
"custodian": {
"is_included": 1,
"value": "14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS"
}
}
}
],
"luts": []
}
},
"result": {
"expected_signature": "b92c3f408965ceee6512ede6dec12b0436eb62e9631b5f9a4eef33384a745f0d57d583cb808ae41f2cfb24ffa768738724269a3f528be491e64162b016cbce03"
}
},
{
"description": "Merge",
"parameters": {
"address": "m/44'/501'/0'/0'",
"construct": {
"version": null,
"header": {
"signers": 1,
"readonly_signers": 0,
"readonly_non_signers": 3
},
"accounts": [
"14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS",
"AeDJ1BqA7ruBbd6mEcS1QNxFbT8FQbiBVuN9NqK94Taq",
"ATFXMD5cYiw9yHkvexgx3nf9LNSouEViB5BZBsgwunAv",
"Stake11111111111111111111111111111111111111",
"SysvarC1ock11111111111111111111111111111111",
"SysvarStakeHistory1111111111111111111111111"
],
"blockhash": "2p4rYZAaFfV5Uk5ugdG5KPNty9Uda9B3b4gWB8qnNqak",
"instructions": [
{
"program_index": 3,
"accounts": {
"destination_stake_account": 2,
"source_stake_account": 1,
"clock_sysvar": 4,
"stake_history_sysvar": 5,
"stake_authority": 0
},
"data": {
"instruction_id": 7
}
}
],
"luts": []
}
},
"result": {
"expected_signature": "e2035c812b38b6524698c1e77fff5470471dc5c0a9a163e6a0d236b41f3ccf5ab0c03b2e5694f3776f5cf8c1838e47b429f4e52389e118665e6d609db4e0d30c"
}
},
{
"description": "Authorize With Seed",
"parameters": {
"address": "m/44'/501'/0'/0'",
"construct": {
"version": null,
"header": {
"signers": 1,
"readonly_signers": 0,
"readonly_non_signers": 2
},
"accounts": [
"14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS",
"ATFXMD5cYiw9yHkvexgx3nf9LNSouEViB5BZBsgwunAv",
"Stake11111111111111111111111111111111111111",
"SysvarC1ock11111111111111111111111111111111"
],
"blockhash": "2p4rYZAaFfV5Uk5ugdG5KPNty9Uda9B3b4gWB8qnNqak",
"instructions": [
{
"program_index": 2,
"accounts": {
"stake_account": 1,
"stake_or_withdraw_authority": 0,
"clock_sysvar": 3,
"lockup_authority": null
},
"data": {
"instruction_id": 8,
"new_authorized_pubkey": "ETxHeBBcuw9Yu4dGuP3oXrD12V5RECvmi8ogQ9PkjyVF",
"stake_authorize": 1,
"authority_seed": {
"length": 7,
"chars": "stake:0"
},
"authority_owner": "11111111111111111111111111111111"
}
}
],
"luts": []
}
},
"result": {
"expected_signature": "2cfb0d5ad4e2674d20ee7c5dc64c5d7068ae2a31019662b940239394769843f7df77d596ff8f9dfac78ab0f264bacc9c38b806d210eddd5870d68d923c558c0b"
}
},
{
"description": "Initialize Checked",
"parameters": {
"address": "m/44'/501'/0'/0'",
"construct": {
"version": null,
"header": {
"signers": 1,
"readonly_signers": 0,
"readonly_non_signers": 3
},
"accounts": [
"14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS",
"GpX913B4PeKzzukWw4zyqz76smpExLysTTDR4rYUiijM",
"11111111111111111111111111111111",
"Stake11111111111111111111111111111111111111",
"SysvarRent111111111111111111111111111111111"
],
"blockhash": "2NuqEwZcMwFQyQaKGaLiFSFBpJaW1er26cni1sBDAeKw",
"instructions": [
{
"program_index": 2,
"accounts": {
"funding_account": 0,
"created_account": 1,
"base_account": 0
},
"data": {
"instruction_id": 3,
"base": "14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS",
"seed": {
"length": 7,
"chars": "stake:1"
},
"lamports": 3000000,
"space": 200,
"owner": "Stake11111111111111111111111111111111111111"
}
},
{
"program_index": 3,
"accounts": {
"uninitialized_stake_account": 1,
"rent_sysvar": 4,
"stake_authority": 0,
"withdrawal_authority": 0
},
"data": {
"instruction_id": 9
}
}
],
"luts": []
}
},
"result": {
"expected_signature": "f34b9eb5f586a320b919ad6dcc3f51553d3d08f5a1260279973d9fa4250bc61658a38a51322c0586b0e73b7e66325a46b8f4b60828d35e7da1013e84fa12540e"
}
},
{
"description": "Authorize Checked",
"parameters": {
"address": "m/44'/501'/0'/0'",
"construct": {
"version": null,
"header": {
"signers": 1,
"readonly_signers": 0,
"readonly_non_signers": 2
},
"accounts": [
"14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS",
"ATFXMD5cYiw9yHkvexgx3nf9LNSouEViB5BZBsgwunAv",
"Stake11111111111111111111111111111111111111",
"SysvarC1ock11111111111111111111111111111111"
],
"blockhash": "5AMCR1wLcR4nVUn3w6h4cK6UYjkdKc6SXNGP9Hj8vNUc",
"instructions": [
{
"program_index": 2,
"accounts": {
"stake_account": 1,
"clock_sysvar": 3,
"stake_or_withdraw_authority": 0,
"new_stake_or_withdraw_authority": 0
},
"data": {
"instruction_id": 10,
"stake_authorize": 0
}
},
{
"program_index": 2,
"accounts": {
"stake_account": 1,
"clock_sysvar": 3,
"stake_or_withdraw_authority": 0,
"new_stake_or_withdraw_authority": 0
},
"data": {
"instruction_id": 10,
"stake_authorize": 1
}
}
],
"luts": []
}
},
"result": {
"expected_signature": "fc71a9bb988196ed145373531e9b2bcd590177a398a102779290d665c8cbd5dbc5e8c9144ff1165d98f241ebc0747c0715b1e43056fabf85f15fc594d5460c0b"
}
},
{
"description": "Authorize Checked with Seed",
"parameters": {
"address": "m/44'/501'/0'/0'",
"construct": {
"version": null,
"header": {
"signers": 1,
"readonly_signers": 0,
"readonly_non_signers": 2
},
"accounts": [
"14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS",
"ATFXMD5cYiw9yHkvexgx3nf9LNSouEViB5BZBsgwunAv",
"Stake11111111111111111111111111111111111111",
"SysvarC1ock11111111111111111111111111111111"
],
"blockhash": "5AMCR1wLcR4nVUn3w6h4cK6UYjkdKc6SXNGP9Hj8vNUc",
"instructions": [
{
"program_index": 2,
"accounts": {
"stake_account": 1,
"stake_or_withdraw_authority": 0,
"clock_sysvar": 3,
"new_stake_or_withdraw_authority": 0
},
"data": {
"instruction_id": 11,
"stake_authorize": 0,
"authority_seed": {
"length": 11,
"chars": "authority:1"
},
"authority_owner": "14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS"
}
}
],
"luts": []
}
},
"result": {
"expected_signature": "01e7a9a28036b36b8dbe8a68823c03330558dd8c0627fd5f25d2fa1556b43e47e23885cb71790ad444ab8e603dedbe759faa7312d5ff8921025307c42d8a3100"
}
},
{
"description": "Set Lockup Checked",
"parameters": {
"address": "m/44'/501'/0'/0'",
"construct": {
"version": null,
"header": {
"signers": 1,
"readonly_signers": 0,
"readonly_non_signers": 1
},
"accounts": [
"14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS",
"ATFXMD5cYiw9yHkvexgx3nf9LNSouEViB5BZBsgwunAv",
"Stake11111111111111111111111111111111111111"
],
"blockhash": "2UZYH9e662w7SoLiwnGyGZY1Mn5YjEkWEozZGm5ViR6Q",
"instructions": [
{
"program_index": 2,
"accounts": {
"stake_account": 1,
"lockup_or_withdraw_authority": 0,
"new_lockup_authority": 0
},
"data": {
"instruction_id": 12,
"unix_timestamp": {
"is_included": 1,
"value": 482196050
},
"epoch": {
"is_included": 1,
"value": 20
}
}
}
],
"luts": []
}
},
"result": {
"expected_signature": "42b06682b7cc946143dece29c7014e408d37768d8dcd28c5293c0b13c35000cbf771886dfd4a2f1cad487621b46167d4b32ecc51c605bef0f450da6761952e05"
}
},
{
"description": "Create Stake Account",
"parameters": {
"address": "m/44'/501'/0'/0'",
"construct": {
"version": null,
"header": {
"signers": 2,
"readonly_signers": 0,
"readonly_non_signers": 3
},
"accounts": [
"14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS",
"ATFXMD5cYiw9yHkvexgx3nf9LNSouEViB5BZBsgwunAv",
"11111111111111111111111111111111",
"Stake11111111111111111111111111111111111111",
"SysvarRent111111111111111111111111111111111"
],
"blockhash": "2p4rYZAaFfV5Uk5ugdG5KPNty9Uda9B3b4gWB8qnNqak",
"instructions": [
{
"program_index": 2,
"accounts": {
"funding_account": 0,
"new_account": 1
},
"data": {
"instruction_id": 0,
"lamports": 20000000,
"space": 1000,
"owner": "Stake11111111111111111111111111111111111111"
}
},
{
"program_index": 3,
"accounts": {
"uninitialized_stake_account": 1,
"rent_sysvar": 4
},
"data": {
"instruction_id": 0,
"staker": "14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS",
"withdrawer": "14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS",
"unix_timestamp": 0,
"epoch": 0,
"custodian": "11111111111111111111111111111111"
}
}
],
"luts": []
}
},
"result": {
"expected_signature": "e99a383ce8f9fcd0ebbb03fce2c47db188734bd36613d226110dfa9d95ba28ad55c4e3ff36d1c4936538350d96d7aeff024c3e6afbb5c45dfe921a18e981ea0c"
}
}
]
}

View File

@ -0,0 +1,586 @@
{
"setup": {
"mnemonic": "all all all all all all all all all all all all",
"passphrase": ""
},
"tests": [
{
"description": "Create Account",
"parameters": {
"address": "m/44'/501'/0'/0'",
"construct": {
"version": null,
"header": {
"signers": 2,
"readonly_signers": 0,
"readonly_non_signers": 1
},
"accounts": [
"14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS",
"AeDJ1BqA7ruBbd6mEcS1QNxFbT8FQbiBVuN9NqK94Taq",
"11111111111111111111111111111111"
],
"blockhash": "2p4rYZAaFfV5Uk5ugdG5KPNty9Uda9B3b4gWB8qnNqak",
"instructions": [
{
"program_index": 2,
"accounts": {
"funding_account": 0,
"new_account": 1
},
"data": {
"instruction_id": 0,
"lamports": 20000000,
"space": 1000,
"owner": "11111111111111111111111111111111"
}
}
],
"luts": []
}
},
"result": {
"expected_signature": "aa5d16f3f67860182ac8170c0a10941c1bf2ae788ea0e9a06f09d8a8be0543bc7d9d1d485f7caed99653a5bb17d9ad70768c2fca14f80c7ab79aad19f6c81a00"
}
},
{
"description": "Assign",
"parameters": {
"address": "m/44'/501'/0'/0'",
"construct": {
"version": null,
"header": {
"signers": 1,
"readonly_signers": 0,
"readonly_non_signers": 1
},
"accounts": [
"14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS",
"11111111111111111111111111111111"
],
"blockhash": "2p4rYZAaFfV5Uk5ugdG5KPNty9Uda9B3b4gWB8qnNqak",
"instructions": [
{
"program_index": 1,
"accounts": {
"assigned_account": 0
},
"data": {
"instruction_id": 1,
"owner": "11111111111111111111111111111111"
}
}
],
"luts": []
}
},
"result": {
"expected_signature": "d533f38bcc0b302d2353ee1883217f7cdb283b749ca1b7251b365a4e8c8742b49e8847b759ab845abe2d0b37f4cc916a91a566e40559f5679794cb458be1750e"
}
},
{
"description": "Transfer",
"parameters": {
"address": "m/44'/501'/0'/0'",
"construct": {
"version": null,
"header": {
"signers": 1,
"readonly_signers": 0,
"readonly_non_signers": 1
},
"accounts": [
"14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS",
"ETxHeBBcuw9Yu4dGuP3oXrD12V5RECvmi8ogQ9PkjyVF",
"11111111111111111111111111111111"
],
"blockhash": "2p4rYZAaFfV5Uk5ugdG5KPNty9Uda9B3b4gWB8qnNqak",
"instructions": [
{
"program_index": 2,
"accounts": {
"funding_account": 0,
"recipient_account": 1
},
"data": {
"instruction_id": 2,
"lamports": 200000
}
}
],
"luts": []
}
},
"result": {
"expected_signature": "7d9b551808a878b6dd6255c7b775b7afcd2edb011a1918611d9b72c3fd2f5fe89d8bf30ea41fa6dc91f33e20e9eb07527aadf1e082eb746880167d102a76270c"
}
},
{
"description": "Create Account With Seed",
"parameters": {
"address": "m/44'/501'/0'/0'",
"construct": {
"version": null,
"header": {
"signers": 1,
"readonly_signers": 0,
"readonly_non_signers": 1
},
"accounts": [
"14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS",
"ByFfsNTE1vJcgfqFmdJz8gXVHbDuNUnKXunSpm1hjKxU",
"11111111111111111111111111111111"
],
"blockhash": "2p4rYZAaFfV5Uk5ugdG5KPNty9Uda9B3b4gWB8qnNqak",
"instructions": [
{
"program_index": 2,
"accounts": {
"funding_account": 0,
"created_account": 1
},
"data": {
"instruction_id": 3,
"base": "14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS",
"seed": {
"length": 6,
"chars": "seed:1"
},
"lamports": 20000000,
"space": 0,
"owner": "11111111111111111111111111111111"
}
}
],
"luts": []
}
},
"result": {
"expected_signature": "7a84a43d6397d8e8ae8fc508c78a02edde84e9a027e74545e9fa338757ffee165adc41c32f56b023fa6e1ce1f0b6e5a2723ddcf84e2bac2bfaccad786d1f310a"
}
},
{
"description": "Advance Nonce Account",
"parameters": {
"address": "m/44'/501'/0'/0'",
"construct": {
"version": null,
"header": {
"signers": 1,
"readonly_signers": 0,
"readonly_non_signers": 2
},
"accounts": [
"14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS",
"AeDJ1BqA7ruBbd6mEcS1QNxFbT8FQbiBVuN9NqK94Taq",
"11111111111111111111111111111111",
"SysvarRecentB1ockHashes11111111111111111111"
],
"blockhash": "2p4rYZAaFfV5Uk5ugdG5KPNty9Uda9B3b4gWB8qnNqak",
"instructions": [
{
"program_index": 2,
"accounts": {
"nonce_account": 1,
"recent_blockhashes_sysvar": 3,
"nonce_authority": 0
},
"data": {
"instruction_id": 4
}
}
],
"luts": []
}
},
"result": {
"expected_signature": "1e87379f8d601f582c23f84daad03450161c37ab4b64822fa845821e2ed5df5e7c922e8e3a87f51f986252016a5ceef0d443542f0c1ca8479cf4d62aa80cfd09"
}
},
{
"description": "Withdraw Nonce Account",
"parameters": {
"address": "m/44'/501'/0'/0'",
"construct": {
"version": null,
"header": {
"signers": 1,
"readonly_signers": 0,
"readonly_non_signers": 3
},
"accounts": [
"14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS",
"AeDJ1BqA7ruBbd6mEcS1QNxFbT8FQbiBVuN9NqK94Taq",
"11111111111111111111111111111111",
"SysvarRecentB1ockHashes11111111111111111111",
"SysvarRent111111111111111111111111111111111"
],
"blockhash": "2p4rYZAaFfV5Uk5ugdG5KPNty9Uda9B3b4gWB8qnNqak",
"instructions": [
{
"program_index": 2,
"accounts": {
"nonce_account": 1,
"recipient_account": 0,
"recent_blockhashes_sysvar": 3,
"rent_sysvar": 4,
"nonce_authority": 0
},
"data": {
"instruction_id": 5,
"lamports": 200000
}
}
],
"luts": []
}
},
"result": {
"expected_signature": "c43d76dc84a56f5014c7f853a6a7ed41c094cec70c26b602703ec50f5bfe525b96ddcbf8f69eae16d6290f5aca5096e3c5a515d1742d975000883a1c3d04390e"
}
},
{
"description": "Initialize Nonce Account",
"parameters": {
"address": "m/44'/501'/0'/0'",
"construct": {
"version": null,
"header": {
"signers": 1,
"readonly_signers": 0,
"readonly_non_signers": 3
},
"accounts": [
"14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS",
"AeDJ1BqA7ruBbd6mEcS1QNxFbT8FQbiBVuN9NqK94Taq",
"11111111111111111111111111111111",
"SysvarRecentB1ockHashes11111111111111111111",
"SysvarRent111111111111111111111111111111111"
],
"blockhash": "2p4rYZAaFfV5Uk5ugdG5KPNty9Uda9B3b4gWB8qnNqak",
"instructions": [
{
"program_index": 2,
"accounts": {
"nonce_account": 1,
"recent_blockhashes_sysvar": 3,
"rent_sysvar": 4
},
"data": {
"instruction_id": 6,
"nonce_authority": "14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS"
}
}
],
"luts": []
}
},
"result": {
"expected_signature": "7dc7f032ee3ca32a52b11c8f66e414058b6d14a5b21799a4e44201a4cc1394ed8e9237b1e9bb81f56ccf4bdef3034d9fccb257e58945fce3f63f2539039f1306"
}
},
{
"description": "Authorize Nonce Account",
"parameters": {
"address": "m/44'/501'/0'/0'",
"construct": {
"version": null,
"header": {
"signers": 1,
"readonly_signers": 0,
"readonly_non_signers": 1
},
"accounts": [
"14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS",
"AeDJ1BqA7ruBbd6mEcS1QNxFbT8FQbiBVuN9NqK94Taq",
"11111111111111111111111111111111"
],
"blockhash": "2p4rYZAaFfV5Uk5ugdG5KPNty9Uda9B3b4gWB8qnNqak",
"instructions": [
{
"program_index": 2,
"accounts": {
"nonce_account": 1,
"nonce_authority": 0
},
"data": {
"instruction_id": 7,
"nonce_authority": "ETxHeBBcuw9Yu4dGuP3oXrD12V5RECvmi8ogQ9PkjyVF"
}
}
],
"luts": []
}
},
"result": {
"expected_signature": "cba3c4a5f24c775fc4e39e4e01395caeec0749a6ed0ab1e2beae3db07ba69f22d71cd4c1f11f743d0d394e8d297fc57788a916d1791eb9acae0533e8b125ba03"
}
},
{
"description": "Allocate",
"parameters": {
"address": "m/44'/501'/0'/0'",
"construct": {
"version": null,
"header": {
"signers": 1,
"readonly_signers": 0,
"readonly_non_signers": 1
},
"accounts": [
"14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS",
"11111111111111111111111111111111"
],
"blockhash": "2p4rYZAaFfV5Uk5ugdG5KPNty9Uda9B3b4gWB8qnNqak",
"instructions": [
{
"program_index": 1,
"accounts": {
"new_account": 0
},
"data": {
"instruction_id": 8,
"space": 200
}
}
],
"luts": []
}
},
"result": {
"expected_signature": "c910c3be30a17014e31e301c24516d44c8d8fc346de9e5e90505ed97c7c62fd1012353d9bb2a24bf254aa7b6627606a28f0e0402547517e506c873bda218a305"
}
},
{
"description": "Allocate With Seed",
"parameters": {
"address": "m/44'/501'/0'/0'",
"construct": {
"version": null,
"header": {
"signers": 1,
"readonly_signers": 0,
"readonly_non_signers": 1
},
"accounts": [
"14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS",
"ByFfsNTE1vJcgfqFmdJz8gXVHbDuNUnKXunSpm1hjKxU",
"11111111111111111111111111111111"
],
"blockhash": "2p4rYZAaFfV5Uk5ugdG5KPNty9Uda9B3b4gWB8qnNqak",
"instructions": [
{
"program_index": 2,
"accounts": {
"allocated_account": 1,
"base_account": 0
},
"data": {
"instruction_id": 9,
"base": "14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS",
"seed": {
"length": 6,
"chars": "seed:0"
},
"space": 22200,
"owner": "11111111111111111111111111111111"
}
}
],
"luts": []
}
},
"result": {
"expected_signature": "6beb42dfccb317bae7fa4e8ad09e218d27853686207d25b8462f8760c918a21e44c387a55b6750727305eaa995461eb42a4a17aec8d6d7257b45642ed457da07"
}
},
{
"description": "Assign With Seed",
"parameters": {
"address": "m/44'/501'/0'/0'",
"construct": {
"version": null,
"header": {
"signers": 1,
"readonly_signers": 0,
"readonly_non_signers": 1
},
"accounts": [
"14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS",
"ByFfsNTE1vJcgfqFmdJz8gXVHbDuNUnKXunSpm1hjKxU",
"11111111111111111111111111111111"
],
"blockhash": "2p4rYZAaFfV5Uk5ugdG5KPNty9Uda9B3b4gWB8qnNqak",
"instructions": [
{
"program_index": 2,
"accounts": {
"assigned_account": 1,
"base_account": 0
},
"data": {
"instruction_id": 10,
"base": "14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS",
"seed": {
"length": 6,
"chars": "seed:0"
},
"owner": "11111111111111111111111111111111"
}
}
],
"luts": []
}
},
"result": {
"expected_signature": "3bf731a9508faa94e194c4d0475a266bf19548ac5292a5fc817a62dee2798313a4a8eec118c6648efd7021e684bf3238eda56279af47cbc8567133acfcbfc804"
}
},
{
"description": "Transfer With Seed",
"parameters": {
"address": "m/44'/501'/0'/0'",
"construct": {
"version": null,
"header": {
"signers": 1,
"readonly_signers": 0,
"readonly_non_signers": 1
},
"accounts": [
"14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS",
"ByFfsNTE1vJcgfqFmdJz8gXVHbDuNUnKXunSpm1hjKxU",
"11111111111111111111111111111111"
],
"blockhash": "2p4rYZAaFfV5Uk5ugdG5KPNty9Uda9B3b4gWB8qnNqak",
"instructions": [
{
"program_index": 2,
"accounts": {
"funding_account": 0,
"base_account": 0,
"recipient_account": 1
},
"data": {
"instruction_id": 11,
"lamports": 200000,
"from_seed": {
"length": 6,
"chars": "seed:0"
},
"from_owner": "11111111111111111111111111111111"
}
}
],
"luts": []
}
},
"result": {
"expected_signature": "18e6373c7f0374a0901c72957e6931a45bc8572493c591ff0dad975762fb03dafbc1a99e903291bf5c0de665fe961951e43d5fa0c3f48dfdc6e1e2e7c471310b"
}
},
{
"description": "Lookup tables",
"parameters": {
"address": "m/44'/501'/0'/0'",
"construct": {
"version": 0,
"header": {
"signers": 1,
"readonly_signers": 0,
"readonly_non_signers": 1
},
"accounts": [
"14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS",
"11111111111111111111111111111111"
],
"blockhash": "2p4rYZAaFfV5Uk5ugdG5KPNty9Uda9B3b4gWB8qnNqak",
"instructions": [
{
"program_index": 1,
"accounts": {
"funding_account": 0,
"recipient_account": 2
},
"data": {
"instruction_id": 2,
"lamports": 20000000
}
},
{
"program_index": 1,
"accounts": {
"funding_account": 0,
"recipient_account": 3
},
"data": {
"instruction_id": 2,
"lamports": 30000000
}
},
{
"program_index": 1,
"accounts": {
"funding_account": 0,
"recipient_account": 4
},
"data": {
"instruction_id": 2,
"lamports": 40000000
}
}
],
"luts": [
{
"account": "AeDJ1BqA7ruBbd6mEcS1QNxFbT8FQbiBVuN9NqK94Taq",
"readwrite": [0, 1],
"readonly": []
},
{
"account": "H8JEG2wjU2LnjXJUVkivEokcK1pmtHXTyoGeDaBtazCy",
"readwrite": [0],
"readonly": []
}
]
}
},
"result": {
"expected_signature": "18cfc28c0119e9045b3ead4e82cfee79450ecda7e18835d0461278c1df0e6dee4c75ad01fab32c3d395390703fc755e68f8de1832e8b3f8503c0fbc82359af0b"
}
},
{
"description": "Upgrade Nonce",
"parameters": {
"address": "m/44'/501'/0'/0'",
"construct": {
"version": null,
"header": {
"signers": 1,
"readonly_signers": 0,
"readonly_non_signers": 0
},
"accounts": [
"14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS",
"11111111111111111111111111111111"
],
"blockhash": "2p4rYZAaFfV5Uk5ugdG5KPNty9Uda9B3b4gWB8qnNqak",
"instructions": [
{
"program_index": 1,
"accounts": {
"nonce_account": 0
},
"data": {
"instruction_id": 12
}
}
],
"luts": []
}
},
"result": {
"expected_signature": "94fc370a351e845aae30832ee8101d6859c0fecff4b88cb7ec2faae1f30f930564724093a6ef924f2584898fbf6c3e54101eeaa9a7b04baab421d961341f220f"
}
}
]
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,39 @@
{
"setup": {
"mnemonic": "all all all all all all all all all all all all",
"passphrase": ""
},
"tests": [
{
"description": "Unknown instruction",
"parameters": {
"address": "m/44'/501'/0'/0'",
"construct": {
"version": null,
"header": {
"signers": 2,
"readonly_signers": 0,
"readonly_non_signers": 1
},
"accounts": [
"14CCvQzQzHCVgZM3j9soPnXuJXh1RmCfwLVUcdfbZVBS",
"AeDJ1BqA7ruBbd6mEcS1QNxFbT8FQbiBVuN9NqK94Taq",
"AeDJ1BqA7ruBbd6mEcS1QNxFbT8FQbiBVuN9NqK94Taq"
],
"blockhash": "2p4rYZAaFfV5Uk5ugdG5KPNty9Uda9B3b4gWB8qnNqak",
"instructions": [
{
"program_index": 2,
"accounts": [0, 1],
"data": "04deadbeef"
}
],
"luts": []
}
},
"result": {
"expected_signature": "90093762546ad274def9b20ca6c441564193f2c7213cac704aefc6b7d65ebb315415fa7528728279a6688e2c99aa572d5af17b21a15a1d06b94e03df4ce53205"
}
}
]
}

View File

@ -0,0 +1,92 @@
from construct import (
AdaptationError,
Adapter,
Byte,
Bytes,
Construct,
GreedyString,
If,
Int64ul,
Optional,
PaddedString,
Prefixed,
PrefixedArray,
Struct,
Validator,
VarInt,
this,
)
from trezorlib.tools import b58decode, b58encode
def _find_in_context(context, key: str):
if key in context:
return context[key]
elif context._ is not None:
return _find_in_context(context._, key)
else:
return None
class VersionEncodingAdapter(Adapter):
def _decode(self, obj: int, context, path) -> str | int:
if obj & 0x80:
return obj - 0x80
raise AdaptationError
def _encode(self, obj: int, context, path) -> int:
return obj | 0x80
Version = Optional(VersionEncodingAdapter(Byte))
class CompactU16Validator(Validator):
def _validate(self, obj: int, context, path) -> bool:
return obj < 0x1_0000
CompactU16 = CompactU16Validator(VarInt)
def CompactArray(subcon: Construct):
return PrefixedArray(CompactU16, subcon)
def CompactStruct(*subcons, **subconskw):
return Prefixed(CompactU16, Struct(*subcons, **subconskw))
class B58Adapter(Adapter):
def _decode(self, obj: str, context, path) -> str:
# decode/encode is flipped because we are deserializing ("decoding") by representing ("encoding") the bytes in Base58
return b58encode(obj)
def _encode(self, obj: str, context, path) -> bytes:
# decode/encode is flipped because we are serializing ("encoding") by parsing ("decoding") the Base58 string
return b58decode(obj)
PublicKey = B58Adapter(Bytes(32))
class HexStringAdapter(Adapter):
def _decode(self, obj: bytes, context, path) -> str:
return obj.hex()
def _encode(self, obj: str, context, path) -> bytes:
return bytes.fromhex(obj)
Memo = GreedyString("utf8")
String = Struct("length" / Int64ul, "chars" / PaddedString(this.length, "utf-8"))
def OptionalParameter(subcon: Construct):
return Struct(
"is_included" / Byte,
"value" / Optional(If(this.is_included == 1, subcon)),
)

View File

@ -0,0 +1,37 @@
from construct import Byte, GreedyBytes, If, Int8ul, Prefixed, RawCopy, Struct, this
from .custom_constructs import CompactArray, CompactU16, PublicKey, Version
Header = Struct(
"signers" / Int8ul,
"readonly_signers" / Int8ul,
"readonly_non_signers" / Int8ul,
)
Accounts = CompactArray(PublicKey)
Lut = Struct(
"account" / PublicKey,
"readwrite" / CompactArray(Int8ul),
"readonly" / CompactArray(Int8ul),
)
Luts = CompactArray(Lut)
RawInstruction = RawCopy(
Struct(
"program_id" / Byte,
"accounts" / CompactArray(Byte),
"data" / Prefixed(CompactU16, GreedyBytes),
)
)
Message = Struct(
"version" / Version,
"header" / Header,
"accounts" / Accounts,
"blockhash" / PublicKey,
"instructions" / CompactArray(RawInstruction),
"luts" / If(this.version != None, Luts), # noqa: E711
)

View File

@ -0,0 +1,77 @@
# This file is part of the Trezor project.
#
# Copyright (C) 2012-2023 SatoshiLabs and contributors
#
# This library is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License version 3
# as published by the Free Software Foundation.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the License along with this library.
# If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.
import pytest
from trezorlib.debuglink import TrezorClientDebugLink as Client
from trezorlib.solana import sign_tx
from trezorlib.tools import parse_path
from ...common import parametrize_using_common_fixtures
from .construct.instructions import PROGRAMS, UnknownInstruction
from .construct.transaction import Message, RawInstruction
pytestmark = [
pytest.mark.altcoin,
pytest.mark.solana,
pytest.mark.skip_t1,
]
@parametrize_using_common_fixtures(
"solana/sign_tx.system_program.json",
"solana/sign_tx.stake_program.json",
"solana/sign_tx.associated_token_account_program.json",
"solana/sign_tx.memo_program.json",
"solana/sign_tx.compute_budget_program.json",
"solana/sign_tx.token_program.json",
"solana/sign_tx.unknown_instructions.json",
)
def test_solana_sign_tx(client: Client, parameters, result):
client.init_device(new_session=True)
serialized_tx = _serialize_tx(parameters["construct"])
actual_result = sign_tx(
client,
address_n=parse_path(parameters["address"]),
serialized_tx=serialized_tx,
)
assert actual_result.signature == bytes.fromhex(result["expected_signature"])
def _serialize_tx(tx_construct):
serialized_instructions = []
for instruction in tx_construct["instructions"]:
program = tx_construct["accounts"][instruction["program_index"]]
builder = PROGRAMS.get(program, UnknownInstruction)
serialized_instruction = builder.build(instruction)
raw_instruction = RawInstruction.parse(serialized_instruction)
serialized_instructions.append(raw_instruction)
message_construct = {
"version": tx_construct["version"],
"header": tx_construct["header"],
"accounts": tx_construct["accounts"],
"blockhash": tx_construct["blockhash"],
"instructions": serialized_instructions,
"luts": tx_construct["luts"],
}
return Message.build(
message_construct,
)