Skip to content

Commit

Permalink
chore(LLC): add token account serialization test
Browse files Browse the repository at this point in the history
  • Loading branch information
mikhd committed Jul 12, 2024
1 parent e67ea25 commit 08b94a6
Show file tree
Hide file tree
Showing 2 changed files with 120 additions and 0 deletions.
26 changes: 26 additions & 0 deletions libs/ledger-live-common/src/account/serialization.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { getCryptoCurrencyById, getTokenById, setSupportedCurrencies } from "../currencies";
import { genAccount, genTokenAccount } from "@ledgerhq/coin-framework/mocks/account";
import { toAccountRaw, fromAccountRaw } from "./serialization";
import { setWalletAPIVersion } from "../wallet-api/version";
import { WALLET_API_VERSION } from "../wallet-api/constants";

setWalletAPIVersion(WALLET_API_VERSION);

setSupportedCurrencies(["solana"]);
const Solana = getCryptoCurrencyById("solana");
const USDC = getTokenById("solana/spl/EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v");

describe("serialization", () => {
test("TokenAccount extra fields should be serialized/deserialized", () => {
const acc: any = genAccount("mocked-account-1", { currency: Solana });
const tokenAcc: any = genTokenAccount(1, acc, USDC);
tokenAcc.state = "initialized";
acc.subAccounts = [tokenAcc];

const accRaw: any = toAccountRaw(acc);
expect(accRaw.subAccounts?.[0]?.state).toBe("initialized");

const deserializedAcc: any = fromAccountRaw(accRaw);
expect(deserializedAcc.subAccounts?.[0]?.state).toBe("initialized");
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -906,6 +906,7 @@ exports[`sortCurrenciesByIds snapshot 1`] = `
"ethereum/erc20/ksm_starter_token",
"ethereum/erc20/aditus",
"ethereum/erc20/ethopt_io",
"solana/spl/SHDWyBxihqiCj6YekG2GUr7wqKLeLAMK1gHZck9pL6y",
"ethereum/erc20/bigboom",
"ethereum/erc20/realchain",
"ethereum/erc20/ink_protocol",
Expand Down Expand Up @@ -15032,5 +15033,98 @@ exports[`sortCurrenciesByIds snapshot 1`] = `
"cardano/native/f7c777fdd4531cf1c477551360e45b9684073c05c2fa61334f8f9add5665726974726565546f6b656e",
"stellar/asset/USDC:GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN",
"casper/asset/USDC:GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN",
"solana/spl/2VhjJ9WxaGC3EZFwJG9BDUs9KxKCAjQY4vgd1qxgYWVg",
"solana/spl/35r2jMGKytAJ7FyKfKRHPanT8kpjg3emPy7WG6GANCNB",
"solana/spl/3bRTivrVsitbmCTGtqwp7hxXPsybkjn4XLNtPsHqa3zR",
"solana/spl/3dgCCb15HMQSA4Pn3Tfii5vRk7aRqTH95LJjxzsG2Mug",
"solana/spl/4k3Dyjzvzp8eMZWUXbBCjEvwSkkk59S5iCNLY3QrkX6R",
"solana/spl/4vMsoUT2BWatFweudnQM1xedRLfJgJ7hswhcpz4xgBTy",
"solana/spl/5MAYDfq5yxtudAhtfyuMBuHZjgAbaS9tbEyEQYAhDS5y",
"solana/spl/5oVNBeEEQvYi1cX3ir8Dx5n1P7pdxydbGF2X4TxVusJm",
"solana/spl/5tB5D6DGJMxxHYmNkfJNG237x6pZGEwTzGpUUh62yQJ7",
"solana/spl/6cVgJUqo4nmvQpbgrDZwyfd6RwWw5bfnCamS3M9N1fd",
"solana/spl/6DNSN2BJsaPFdFFc1zP37kkeNe4Usc1Sqkzr9C9vPWcU",
"solana/spl/6LX8BhMQ4Sy2otmAWj7Y5sKd9YTVVUgfMsBzT6B9W7ct",
"solana/spl/6VNKqgz9hk7zRShTFdg5AnkfKwZUcojzwAkzxSH3bnUm",
"solana/spl/7dHbWXmci3dT8UFYWYZweBLXgycu7Y3iL6trKn1Y7ARj",
"solana/spl/7i5KKsX2weiTkry7jA4ZwSuXGhs5eJBEjY8vVxR4pfRx",
"solana/spl/7kbnvuGBxxj8AG9qp8Scn56muWGaRaFqxg1FsRp3PaFT",
"solana/spl/7Q2afV64in6N6SeZsAAB81TJzwDoD6zpqmHkzi9Dcavn",
"solana/spl/7xKXtg2CW87d97TXJSDpbD5jBkheTqA83TZRuJosgAsU",
"solana/spl/9ET2QCQJdFkeKkuaampNbmicbA8eLYauFCWch9Ddh9p5",
"solana/spl/9mWRABuz2x6koTPCWiCPM49WUbcrNqGTHBV9T9k7y1o7",
"solana/spl/9nEqaUcb16sQ3Tn1psbkWqyhPdLmfHWjKGymREjsAgTE",
"solana/spl/a11bdAAuV8iB2fu7X6AxAvDTo1QZ8FXB3kk5eecdasp",
"solana/spl/A94X2fRy3wydNShU4dRaDyap2UuoeWJGWyATtyp61WZf",
"solana/spl/AFbX8oGjGpmVFywbVouvhQSRmiW2aR1mohfahi4Y2AdB",
"solana/spl/ATLASXmbPQxBUYbxPsV97usA3fPQYEqzQBUHgiFCUsXx",
"solana/spl/AURYydfxJib1ZkTir1Jn1J9ECYUtjb6rKQVmtYaixWPP",
"solana/spl/AZsHEMXd36Bj1EMNXhowJajpUXzrKcK57wW4ZGXVa7yR",
"solana/spl/BgwQjVNMWvt2d8CN51CsbniwRWyZ9H9HfHkEsvikeVuZ",
"solana/spl/BiDB55p4G3n1fGhwKFpxsokBMqgctL4qnZpDH1bVQxMD",
"solana/spl/BKipkearSqAUdNKa1WDstvcMjoPsSKBuNyvKDQDDu9WE",
"solana/spl/BLT1noyNr3GttckEVrtcfC6oyK6yV1DpPgSyXbncMwef",
"solana/spl/bSo13r4TkiE4KumL71LsHTPpL2euBYLFx6h9HP3piy1",
"solana/spl/C98A4nkJXhpVZNAZdHUA95RpTF3T4whtQubL3YobiUX9",
"solana/spl/ChVzxWRmrTeSgwd3Ui3UumcN8KX7VK3WaD4KGeSKpypj",
"solana/spl/CKaKtYvz6dKPyMvYq9Rh3UBrnNqYZAyd7iF4hJtjUvks",
"solana/spl/CRWNYkqdgvhGGae9CKfNka58j6QQkaD5bLhKXvUYqnc1",
"solana/spl/CWBzupvyXN1Cf5rsBEHbzfTFvreLfUaJ77BMNLVJ739y",
"solana/spl/DAtU322C23YpoZyWBm8szk12QyqHa9rUQe1EYXzbm1JE",
"solana/spl/DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263",
"solana/spl/DFL1zNkaGPWm1BqAVqRjCZvHmwTFrEaJtbzJWgseoNJh",
"solana/spl/DkNihsQs1hqEwf9TgKP8FmGv7dmMQ7hnKjS2ZSmMZZBE",
"solana/spl/DUSTawucrTsGU8hcqRdHDCbuYhCPADMLM2VcCb8VnFnQ",
"solana/spl/E5rk3nmgLUuKUiS94gg4bpWwWwyjCMtddsAXkTFLtHEy",
"solana/spl/Ea5SjE2Y6yvCeW5dYTn7PYMuW5ikXkvbGdcmSnXeaLjS",
"solana/spl/EchesyfXePKdLtoiZSL8pBe8Myagyy8ZRqsACNCFGnvp",
"solana/spl/EcQCUYv57C4V6RoPxkVUiDwtX1SP8y8FP5AEToYL8Az",
"solana/spl/EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
"solana/spl/Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB",
"solana/spl/ETAtLmCmsoiEEKfNrHKJ2kYy3MoABhU6NQvpSfij5tDs",
"solana/spl/F3nefJBcejYbtdREjui1T9DPh5dBgpkKq7u2GAAMXs5B",
"solana/spl/Fm9rHUTF5v3hwMLbStjZXqNBBoZyGriQaFM6sTFz3K8A",
"solana/spl/FR87nWEUxVgerFGhZM8Y4AggKGLnaXswr1Pd8wZ4kZcp",
"solana/spl/GDfnEsia2WLAW5t8yx2X5j2mkfA74i5kwGdDuZHt7XmG",
"solana/spl/GDsVXtyt2CBwieKSYMEsjjZXXvqz2G2VwudD7EvXzoEU",
"solana/spl/GENEtH5amGSi8kHAtQoezp1XEXwZJ8vcuePYnXdKrMYz",
"solana/spl/GFX1ZjR2P15tmrSwow6FjyDYcEkoFb4p4gJCpLBjaxHD",
"solana/spl/GsNzxJfFn6zQdJGeYsupJWzUAm57Ba7335mfhWvFiE9Z",
"solana/spl/HBB111SCo9jkCejsZfz8Ec8nH7T6THF8KEKSnvwT6XK6",
"solana/spl/HHjoYwUp5aU6pnrvN4s2pwEErwXNZKhxKGYjRJMoBjLw",
"solana/spl/HhJpBhRRn4g56VsyLuT8DL5Bv31HkXqsrahTTUCZeZg4",
"solana/spl/hntyVP6YFm1Hg25TN9WGLqM12b8TQmcknKrdu1oxWux",
"solana/spl/HxhWkVpk5NS4Ltg5nij2G671CKXFRKPK8vy271Ub4uEK",
"solana/spl/HZ1JovNiVvGrGNiiYvEozEVgZ58xaU3RKwX8eACQBCt3",
"solana/spl/J1toso1uCk3RLmjorhTtrVwY9HJ7X8V9yYac6Y7kGCPn",
"solana/spl/jtojtomepa8beP8AuQc6eXt5FriJwfFMwQx2v2f9mCL",
"solana/spl/kinXdEcpDQeHPEuQnqmUgtYykqKGVFq6CeVX5iAHJq6",
"solana/spl/MangoCzJ36AjZyKwVj3VnYU4GTonjfVEnJmvvWaxLac",
"solana/spl/MAPS41MDahZ9QdKXhVa4dWB9RuyfV4XqhyAZ8XcYepb",
"solana/spl/MEANeD3XDdUmNMsRGjASkSWdC8prLYsoRJ61pPeHctD",
"solana/spl/METAewgxyPbgwsseH8T16a39CQ5VyVxZi9zXiDPY18m",
"solana/spl/MNDEFzGvMt87ueuHvVU9VcTqsAP5b3fTGPsHuuPA5ey",
"solana/spl/mSoLzYCxHdYgdzU16g5QSh3i5K3z3KZK7ytfqcJm7So",
"solana/spl/NFTUkR4u7wKxy9QLaX2TGvd9oZSWoMo4jqSJqdMb7Nk",
"solana/spl/orcaEKTdK7LKz57vaAYr9QeNsVEPfiu6QeMU1kektZE",
"solana/spl/poLisWXnNRwC6oBu1vHiuKQzFjGL4XDSu4g9qjz9qVk",
"solana/spl/PoRTjZMPXb9T7dyU7tpLEZRQj7e6ssfAE62j2oQuc6y",
"solana/spl/PRSMNsEPqhGVCH1TtWiJqPjJyh2cKrLostPZTNy1o5x",
"solana/spl/PsyFiqqjiv41G7o5SMRzDJCu4psptThNR2GtfeGHfSq",
"solana/spl/RLBxxFkseAZ4RgJH3Sqn8jXxhmGoz9jWxDNJMh8pL7a",
"solana/spl/rndrizKT3MK1iimdxRdWabcF7Zg7AR5T4nud4EkHBof",
"solana/spl/Saber2gLauYim4Mvftnrasomsv6NvAuncvMEZwcLpD1",
"solana/spl/SCSuPPNUSypLBsV4darsrYNg4ANPgaGhKhsA3GmMyjz",
"solana/spl/SLCLww7nc1PD2gQPQdGayHviVVcpMthnqUz2iWKhNQV",
"solana/spl/SLNDpmoWTVADgEdndyvWzroNL7zSi1dF9PC3xHGtPwp",
"solana/spl/So11111111111111111111111111111111111111112",
"solana/spl/SRMuApVNdxXokk5GT7XD5cUUgXMBCoAz2LHeuAoKWRt",
"solana/spl/StepAscQoEioFxxWGnh2sLBDFp9d8rvKz2Yp39iDpyT",
"solana/spl/Taki7fi3Zicv7Du1xNAWLaf6mRK7ikdn77HeGzgwvo4",
"solana/spl/TuLipcqtGVXP9XR62wM8WWCm6a9vhLs7T1uoWBk6FDs",
"solana/spl/UXPhBoR3qG4UCiGNJfV7MqhHyFqKN68g45GoYvAeL2M",
"solana/spl/xxxxa1sKNGwFtw2kFn8XauW9xq8hBZ5kVtcSesTT9fW",
"solana/spl/z3dn17yLaGMKffVogeFHQ9zWVcXgqgf3PQnDsNs2g6M",
"solana/spl/zebeczgi5fSEtbpfQKVZKCJ3WgYXxjkMUkNNx7fLKAF",
]
`;

0 comments on commit 08b94a6

Please sign in to comment.