From 8fe3789d1dc3fdf849886e4c5a0db7bebaa86f63 Mon Sep 17 00:00:00 2001 From: Fernando Otero Date: Thu, 16 Jan 2025 13:28:13 +0000 Subject: [PATCH] tests: Add process instruction checks (#19) * Add process instruction checks * Update mollusk git reference * Add missing check * Add return data checks --- Cargo.lock | 568 ++++++++++------- program/Cargo.toml | 2 +- program/tests/assert_instruction_count.rs | 16 +- program/tests/close_account.rs | 102 ++-- program/tests/processor.rs | 714 ++++++++++++++++++++-- program/tests/setup.rs | 17 +- 6 files changed, 1069 insertions(+), 350 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 48b0c96..80c8a52 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -284,9 +284,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.6.0" +version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" +checksum = "8f68f53c83ab957f72c32642f3868eec03eb974d1fb82e453128456482613d36" dependencies = [ "serde", ] @@ -335,11 +335,11 @@ dependencies = [ [[package]] name = "borsh" -version = "1.5.3" +version = "1.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2506947f73ad44e344215ccd6403ac2ae18cd8e046e581a441bf8d199f257f03" +checksum = "9fb65153674e51d3a42c8f27b05b9508cea85edfaade8aa46bc8fc18cecdfef3" dependencies = [ - "borsh-derive 1.5.3", + "borsh-derive 1.5.4", "cfg_aliases", ] @@ -358,15 +358,15 @@ dependencies = [ [[package]] name = "borsh-derive" -version = "1.5.3" +version = "1.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2593a3b8b938bd68373196c9832f516be11fa487ef4ae745eb282e6a56a7244" +checksum = "a396e17ad94059c650db3d253bb6e25927f1eb462eede7e7a153bb6e75dce0a7" dependencies = [ "once_cell", "proc-macro-crate 3.2.0", "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.96", ] [[package]] @@ -439,22 +439,22 @@ dependencies = [ [[package]] name = "bytemuck" -version = "1.20.0" +version = "1.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b37c88a63ffd85d15b406896cc343916d7cf57838a847b3a6f2ca5d39a5695a" +checksum = "ef657dfab802224e671f5818e9a4935f9b1957ed18e58292690cc39e7a4092a3" dependencies = [ "bytemuck_derive", ] [[package]] name = "bytemuck_derive" -version = "1.8.0" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bcfcc3cd946cb52f0bbfdbbcfa2f4e24f75ebb6c0e1002f7c25904fada18b9ec" +checksum = "3fa76293b4f7bb636ab88fd78228235b5248b4d05cc589aed610f954af5d7c7a" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.96", ] [[package]] @@ -471,9 +471,9 @@ checksum = "325918d6fe32f23b19878fe4b34794ae41fc19ddbe53b10571a4874d44ffd39b" [[package]] name = "cc" -version = "1.2.4" +version = "1.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9157bbaa6b165880c27a4293a474c91cdcf265cc68cc829bf10be0964a391caf" +checksum = "c8293772165d9345bdaaa39b45b2109591e63fe5e6fbc23c6ff930a048aa310b" dependencies = [ "shlex", ] @@ -498,7 +498,7 @@ checksum = "45565fc9416b9896014f5732ac776f810ee53a66730c17e4020c3ec064a8f88f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.96", ] [[package]] @@ -663,7 +663,7 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.96", ] [[package]] @@ -687,7 +687,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.90", + "syn 2.0.96", ] [[package]] @@ -698,7 +698,7 @@ checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" dependencies = [ "darling_core", "quote", - "syn 2.0.90", + "syn 2.0.96", ] [[package]] @@ -746,7 +746,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.96", ] [[package]] @@ -822,7 +822,7 @@ checksum = "a1ab991c1362ac86c61ab6f556cff143daa22e5a15e4e189df818b2fd19fe65b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.96", ] [[package]] @@ -903,6 +903,21 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +[[package]] +name = "foreign-types" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" +dependencies = [ + "foreign-types-shared", +] + +[[package]] +name = "foreign-types-shared" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" + [[package]] name = "form_urlencoded" version = "1.2.1" @@ -1317,7 +1332,7 @@ checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.96", ] [[package]] @@ -1389,9 +1404,9 @@ checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674" [[package]] name = "js-sys" -version = "0.3.76" +version = "0.3.77" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6717b6b5b077764fb5966237269cb3c64edddde4b14ce42647430a78ced9e7b7" +checksum = "1cfaf33c695fc6e08064efbc1f72ec937429614f25eef83af942d0e227c3a28f" dependencies = [ "once_cell", "wasm-bindgen", @@ -1414,9 +1429,9 @@ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" -version = "0.2.168" +version = "0.2.169" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aaeb2981e0606ca11d79718f8bb01164f1d6ed75080182d3abf017e6d244b6d" +checksum = "b5aba8db14291edd000dfcc4d620c7ebfb122c613afb886ca8803fa4e128a20a" [[package]] name = "libsecp256k1" @@ -1480,9 +1495,9 @@ dependencies = [ [[package]] name = "linux-raw-sys" -version = "0.4.14" +version = "0.4.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" +checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab" [[package]] name = "litemap" @@ -1502,9 +1517,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.22" +version = "0.4.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" +checksum = "04cbf5b083de1c7e0222a7a51dbfdba1cbe1c6ab0b15e29fff3f6c077fd9cd9f" [[package]] name = "memchr" @@ -1538,9 +1553,9 @@ checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" [[package]] name = "miniz_oxide" -version = "0.8.2" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ffbe83022cedc1d264172192511ae958937694cd57ce297164951b8b3568394" +checksum = "b8402cab7aefae129c6977bb0ff1b8fd9a04eb5b51efc50a70bea51cda0c7924" dependencies = [ "adler2", ] @@ -1559,8 +1574,7 @@ dependencies = [ [[package]] name = "mollusk-svm" version = "0.0.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fceaf67fe3f95a9478f4f5b0d71e77c073eee7a795a74d6143317a22454c289" +source = "git+https://github.com/buffalojoec/mollusk.git#ba391d116e8a032806cb093e7433940fa2cf27b6" dependencies = [ "bincode", "mollusk-svm-error", @@ -1577,8 +1591,7 @@ dependencies = [ [[package]] name = "mollusk-svm-error" version = "0.0.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8738bc85a52d123012209a573f17faffa1db440493396ae2e1f64fbb8f3579bf" +source = "git+https://github.com/buffalojoec/mollusk.git#ba391d116e8a032806cb093e7433940fa2cf27b6" dependencies = [ "solana-sdk", "thiserror 1.0.69", @@ -1587,8 +1600,7 @@ dependencies = [ [[package]] name = "mollusk-svm-keys" version = "0.0.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8a7656d86d743de0a9788ce4c0e9ff63028a42e350131ebe67c476cdde6ac9f" +source = "git+https://github.com/buffalojoec/mollusk.git#ba391d116e8a032806cb093e7433940fa2cf27b6" dependencies = [ "mollusk-svm-error", "solana-sdk", @@ -1647,7 +1659,7 @@ checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.96", ] [[package]] @@ -1709,14 +1721,14 @@ dependencies = [ "proc-macro-crate 3.2.0", "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.96", ] [[package]] name = "object" -version = "0.36.5" +version = "0.36.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aedf0a2d09c573ed1d8d85b30c119153926a2b36dce0ab28322c09a117a4683e" +checksum = "62948e14d923ea95ea2c7c86c71013138b66525b86bdc08d2dcc262bdb497b87" dependencies = [ "memchr", ] @@ -1733,6 +1745,44 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" +[[package]] +name = "openssl" +version = "0.10.68" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6174bc48f102d208783c2c84bf931bb75927a617866870de8a4ea85597f871f5" +dependencies = [ + "bitflags 2.8.0", + "cfg-if", + "foreign-types", + "libc", + "once_cell", + "openssl-macros", + "openssl-sys", +] + +[[package]] +name = "openssl-macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.96", +] + +[[package]] +name = "openssl-sys" +version = "0.9.104" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "45abf306cbf99debc8195b66b7346498d7b10c210de50418b5ccd7ceba08c741" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + [[package]] name = "parking_lot" version = "0.12.3" @@ -1788,9 +1838,9 @@ dependencies = [ [[package]] name = "pin-project-lite" -version = "0.2.15" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "915a1e146535de9163f3987b8944ed8cf49a18bb0056bcebcdcece385cece4ff" +checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b" [[package]] name = "pin-utils" @@ -1798,6 +1848,12 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" +[[package]] +name = "pkg-config" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2" + [[package]] name = "ppv-lite86" version = "0.2.20" @@ -1827,9 +1883,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.92" +version = "1.0.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37d3544b3f2748c54e147655edb5025752e2303145b5aefb3c3ea2c78b973bb0" +checksum = "60946a68e5f9d28b0dc1c21bb8a97ee7d018a8b322fa57838ba31cc878e22d99" dependencies = [ "unicode-ident", ] @@ -1842,7 +1898,7 @@ checksum = "14cae93065090804185d3b75f0bf93b8eeda30c7a9b4a33d3bdb3988d6229e50" dependencies = [ "bit-set", "bit-vec", - "bitflags 2.6.0", + "bitflags 2.8.0", "lazy_static", "num-traits", "rand 0.8.5", @@ -1871,9 +1927,9 @@ checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" [[package]] name = "quote" -version = "1.0.37" +version = "1.0.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" +checksum = "0e4dccaaaf89514f546c693ddc140f729f958c247918a13380cccc6078391acc" dependencies = [ "proc-macro2", ] @@ -1964,7 +2020,7 @@ version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "03a862b389f93e68874fbf580b9de08dd02facb9a788ebadaf4a3fd33cf58834" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.8.0", ] [[package]] @@ -2071,11 +2127,11 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.42" +version = "0.38.43" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f93dc38ecbab2eb790ff964bb77fa94faf256fd3e73285fd7ba0903b76bedb85" +checksum = "a78891ee6bf2340288408954ac787aa063d8e8817e9f53abb37c695c6d834ef6" dependencies = [ - "bitflags 2.6.0", + "bitflags 2.8.0", "errno", "libc", "linux-raw-sys", @@ -2113,6 +2169,12 @@ dependencies = [ "untrusted", ] +[[package]] +name = "rustversion" +version = "1.0.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7c45b9784283f1b2e7fb61b42047c2fd678ef0960d4f6f1eba131594cc369d4" + [[package]] name = "rusty-fork" version = "0.3.0" @@ -2133,9 +2195,9 @@ checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" [[package]] name = "scc" -version = "2.2.6" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94b13f8ea6177672c49d12ed964cca44836f59621981b04a3e26b87e675181de" +checksum = "28e1c91382686d21b5ac7959341fcb9780fa7c03773646995a87c950fa7be640" dependencies = [ "sdd", ] @@ -2176,9 +2238,9 @@ checksum = "3cb6eb87a131f756572d7fb904f6e7b68633f09cca868c5df1c4b8d1a694bbba" [[package]] name = "serde" -version = "1.0.216" +version = "1.0.217" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b9781016e935a97e8beecf0c933758c97a5520d32930e460142b4cd80c6338e" +checksum = "02fc4265df13d6fa1d00ecff087228cc0a2b5f3c0e87e258d8b94a156e984c70" dependencies = [ "serde_derive", ] @@ -2194,20 +2256,20 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.216" +version = "1.0.217" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46f859dbbf73865c6627ed570e78961cd3ac92407a2d117204c49232485da55e" +checksum = "5a9bf7cf98d04a2b28aead066b7496853d4779c9cc183c440dbac457641e19a0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.96", ] [[package]] name = "serde_json" -version = "1.0.133" +version = "1.0.135" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7fceb2473b9166b2294ef05efcb65a3db80803f0b03ef86a5fc88a2b85ee377" +checksum = "2b0d7ba2887406110130a978386c4e1befb98c674b4fba677954e4db976630d9" dependencies = [ "itoa", "memchr", @@ -2229,9 +2291,9 @@ dependencies = [ [[package]] name = "serde_with" -version = "3.11.0" +version = "3.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e28bdad6db2b8340e449f7108f020b3b092e8583a9e3fb82713e1d4e71fe817" +checksum = "d6b6f7f2fcb69f747921f79f3926bd1e203fce4fef62c268dd3abfb6d86029aa" dependencies = [ "serde", "serde_derive", @@ -2240,14 +2302,14 @@ dependencies = [ [[package]] name = "serde_with_macros" -version = "3.11.0" +version = "3.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d846214a9854ef724f3da161b426242d8de7c1fc7de2f89bb1efcb154dca79d" +checksum = "8d00caa5193a3c8362ac2b73be6b9e768aa5a4b2f721d8f4b339600c3cb51f8e" dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.96", ] [[package]] @@ -2272,7 +2334,7 @@ checksum = "5d69265a08751de7844521fd15003ae0a888e035773ba05695c5c759a6f89eef" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.96", ] [[package]] @@ -2354,9 +2416,9 @@ dependencies = [ [[package]] name = "solana-account" -version = "2.1.0" +version = "2.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "730219420b206253977b8cc8fd7846ffe021ab2e2c718e70db420efbd2775547" +checksum = "5fb7cd6b50247886f9ef190d14896c85a4337fe0e648a9aba162a0b2d283cae2" dependencies = [ "bincode", "serde", @@ -2368,9 +2430,9 @@ dependencies = [ [[package]] name = "solana-account-info" -version = "2.1.0" +version = "2.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6abe81cfc4a75f71a510c6856b03a7d8525e416af3c69d55daef62e6078b8d40" +checksum = "e053b991f91fd274df53e070c77a0a6a33681a5102c6421a0ca9ffaa0040368a" dependencies = [ "bincode", "serde", @@ -2381,18 +2443,18 @@ dependencies = [ [[package]] name = "solana-atomic-u64" -version = "2.1.0" +version = "2.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "391b795afcdcad39ddc6c938d64b789d036cdfe00d9dc5ff83024cf2da9f066f" +checksum = "966dce88672728380c476d5d3e54c02025875100b8246db05669961806c9575e" dependencies = [ "parking_lot", ] [[package]] name = "solana-bincode" -version = "2.1.0" +version = "2.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e85cb5961c356345a61378163fd9057011b35540f8bcdd8d8a09cb10117264f" +checksum = "c117b9646b1e9e6c4b48f363ad4c5af25c4ab35754ff307714e5fec2c3c4bb6b" dependencies = [ "bincode", "serde", @@ -2401,9 +2463,9 @@ dependencies = [ [[package]] name = "solana-bn254" -version = "2.1.0" +version = "2.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c39c4030db26ad618f7e18fb5284df19fd52a68e092a1ca58db857108c4cc777" +checksum = "12227c0e89785367be826b51452807c36f31c4f25cf8891da259b699e0de882d" dependencies = [ "ark-bn254", "ark-ec", @@ -2416,19 +2478,19 @@ dependencies = [ [[package]] name = "solana-borsh" -version = "2.1.0" +version = "2.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5d526f3525ab22a3ada3f9a1d642664dafac00dc9208326b701a2045514eb04" +checksum = "7c55b83c305eac62095b6f24ea2ae729f17de47e5a4e866ee4ddd0dc501b351e" dependencies = [ "borsh 0.10.4", - "borsh 1.5.3", + "borsh 1.5.4", ] [[package]] name = "solana-bpf-loader-program" -version = "2.1.0" +version = "2.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "142e0407f8428a1d2a33154d1d3d1c134ad257651ddff0811c17a6ee840def36" +checksum = "bd37acbbdf0c188f74031a144b233f266ed124f3e45c2d24578b1fd5e14a62bb" dependencies = [ "bincode", "byteorder", @@ -2453,29 +2515,30 @@ dependencies = [ [[package]] name = "solana-clock" -version = "2.1.0" +version = "2.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7848171e53fa528efd41dd4b3ab919f47b851f8bb4a827d63ff95678f08737fc" +checksum = "a2387b936492cab0649c2a3e3fcfb282077029b533fa8454c88c41dff3bc2552" dependencies = [ "serde", "serde_derive", "solana-sdk-macro", + "solana-sysvar-id", ] [[package]] name = "solana-compute-budget" -version = "2.1.0" +version = "2.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebf2f023f471bd1195b7f420e13ffc2422592dd48e71104b4901300b49ac493e" +checksum = "91c3a791445139e208e83fde5ddfcbde462f7b90bd21fe8888b8f7d7863af9af" dependencies = [ "solana-sdk", ] [[package]] name = "solana-cpi" -version = "2.1.0" +version = "2.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25c536ad0ce25d84a64f48dedcb773e764827e0ef781eda41fa1fa35f5d64b38" +checksum = "00bae0591481827ac9cfce5573aad2918bb01f91289b811ea531df4fcb73d136" dependencies = [ "solana-account-info", "solana-define-syscall", @@ -2487,9 +2550,9 @@ dependencies = [ [[package]] name = "solana-curve25519" -version = "2.1.0" +version = "2.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f934d38b6f2a940fb1e1d8eaa17a14ffd3773b37be9fb29fa4bcec1bac5e4591" +checksum = "07ec1e9b0cf73334da62f82ac9c19985f18410c2e59f020c0e4a8cf18d1607ef" dependencies = [ "bytemuck", "bytemuck_derive", @@ -2500,24 +2563,24 @@ dependencies = [ [[package]] name = "solana-decode-error" -version = "2.1.0" +version = "2.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5a431f532d030098e81d120877f2dddbd3dd90bea5b259198a6aae4ff6456c3" +checksum = "8880dc18fb97c6205214d1f3ce2f1152e997ecc6f6da4bb458fbf6e6207a0693" dependencies = [ "num-traits", ] [[package]] name = "solana-define-syscall" -version = "2.1.0" +version = "2.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7062ae1de58e294d3bee5fd2c89efc155b7f7383ddce4cb88345dfafaaabc5bd" +checksum = "6452c4a8fc77cc60ad2934b19f2d75691067f17355b34462d52285395c1c99db" [[package]] name = "solana-derivation-path" -version = "2.1.0" +version = "2.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12080d9bf8eecd559c6f40b5aaf9e47f7f28f515218087f83f02e493b46d8388" +checksum = "a03d1149b531c0740a96f36445eec5a937f364729515c924808c40c3706b3b55" dependencies = [ "derivation-path", "qstring", @@ -2526,20 +2589,21 @@ dependencies = [ [[package]] name = "solana-epoch-schedule" -version = "2.1.0" +version = "2.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65c4cf7d7c266d353169cf4feeada5e4bba3a55f33715535fa1ef49080eac3e0" +checksum = "6e783a735416c534228f24f18f18ade0b189c2c8a93be486c9a26bd314517d93" dependencies = [ "serde", "serde_derive", "solana-sdk-macro", + "solana-sysvar-id", ] [[package]] name = "solana-feature-set" -version = "2.1.0" +version = "2.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cebf45992982065a0b01b4e109bf039b2ebf6394b21672382fd951516d4c9b0" +checksum = "cb12f174930110d90589281795fd17e03389e22170461a4d528212865e13c621" dependencies = [ "lazy_static", "solana-clock", @@ -2551,9 +2615,9 @@ dependencies = [ [[package]] name = "solana-fee-calculator" -version = "2.1.0" +version = "2.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2befe056ece2eb5807298c2b569a35ee52f79df859bdd16a1f97869f8224a28" +checksum = "e1fa18582732d94369263c42eeee967ff919e99b9b15ba747fb7534aa24fbbc0" dependencies = [ "log", "serde", @@ -2562,11 +2626,11 @@ dependencies = [ [[package]] name = "solana-hash" -version = "2.1.0" +version = "2.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1807bc4e9e1d25271514167d5a1e698ce5a330bce547a368242dd63b355b5faa" +checksum = "58e35f984e3d60a58184743446250cf724afb34ed65f794da0dc4b462f9c1929" dependencies = [ - "borsh 1.5.3", + "borsh 1.5.4", "bs58", "bytemuck", "bytemuck_derive", @@ -2580,9 +2644,9 @@ dependencies = [ [[package]] name = "solana-inflation" -version = "2.1.0" +version = "2.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a60b572cdf0ec8fcf5a53e5ba4e3e19814dd96c2b9c156d5828be68d0d2e7103" +checksum = "072f2f3562b4a77a1873250e9e6239389887114ed28846c1174e68979ce021a8" dependencies = [ "serde", "serde_derive", @@ -2590,12 +2654,12 @@ dependencies = [ [[package]] name = "solana-instruction" -version = "2.1.0" +version = "2.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfef689e06e5c7cb6206d4dc61ac77733de4f72d754e0d531393206abc27dbe4" +checksum = "35fc69f7f75df0b11e99c03393b24a7443aec0430518054de14715c59cfa716d" dependencies = [ "bincode", - "borsh 1.5.3", + "borsh 1.5.4", "getrandom 0.2.15", "js-sys", "num-traits", @@ -2608,29 +2672,30 @@ dependencies = [ [[package]] name = "solana-last-restart-slot" -version = "2.1.0" +version = "2.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3186feae497bdfd2e77bfa56caed38b1cb1b0f389506666e3331f0b9ae799cb" +checksum = "fee98cc25000ee8bab1a4f63c7516d9521bc8a9747d8287ebb05e5d9b1d32ee1" dependencies = [ "serde", "serde_derive", "solana-sdk-macro", + "solana-sysvar-id", ] [[package]] name = "solana-log-collector" -version = "2.1.0" +version = "2.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b529f5736a6c0794a885dac2e091138d3db6d924335906f117a62b58b0d3b5dc" +checksum = "ff50f7d13f8e5ef4949066d5993a2f4a776a5d713dcd23c3af21c08383f6d3d5" dependencies = [ "log", ] [[package]] name = "solana-logger" -version = "2.1.6" +version = "2.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "037e89416c5f3e160841a3717241f86e5a3e1b3edf4d946e976b4960c11e1073" +checksum = "05de5bd31b0123b9c2c8fa106ae11ad6cff45d77be67a9ac5109407322c58cd4" dependencies = [ "env_logger", "lazy_static", @@ -2639,15 +2704,15 @@ dependencies = [ [[package]] name = "solana-measure" -version = "2.1.0" +version = "2.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33b2047a2f588082b71080b060918f107c3330ae1505f759c3b2d74bae9d9c88" +checksum = "a7ae355064c63c12ffadedc1c44d9410e0fd4f50923f0503a4367c1f64153d2c" [[package]] name = "solana-metrics" -version = "2.1.0" +version = "2.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6319c74238e8ed4f7159fd37c693a574ab8316d03b053103f9cc83dce13f1d5c" +checksum = "18f4af2c5fdda62f1cc6a88a124f5387aa85cb046dd37a992afa85ae05d59d7d" dependencies = [ "crossbeam-channel", "gethostname", @@ -2660,27 +2725,27 @@ dependencies = [ [[package]] name = "solana-msg" -version = "2.1.0" +version = "2.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f7551f85064bc7299d56dbd7126258b084a2d78d0325b1579324f818b405123" +checksum = "fac7a109b0c7a0ed26c1fbf3b0fec8809b5d4c74b5d597f0252d45255fd0d309" dependencies = [ "solana-define-syscall", ] [[package]] name = "solana-native-token" -version = "2.1.0" +version = "2.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d0c4074f5fc67574dabd8f30fe6e51e290a812d88326b19b49c462058e23340" +checksum = "7246817ae265f5a67be25f32ee52267f1c2fe29767ab601ef03c5086bfc64992" [[package]] name = "solana-packet" -version = "2.1.0" +version = "2.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dafc2d84e57dbfe32583fe915962bd2ca3af6be496628a871db3c3d697b38d7" +checksum = "4153becc47f7367102710ae3ddbae46b5aa1b004da4cab8101eaf7d6d0b911b0" dependencies = [ "bincode", - "bitflags 2.6.0", + "bitflags 2.8.0", "cfg_eval", "serde", "serde_derive", @@ -2689,9 +2754,9 @@ dependencies = [ [[package]] name = "solana-poseidon" -version = "2.1.0" +version = "2.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f193a65f0db7fe5615c76c2814d6450a2e4cda61f786d5bf7a6b1ad0c179b947" +checksum = "88a97dd90dd8cc62edf994c146b352fc430a87d7735bb672d6ed1a14d851cc96" dependencies = [ "ark-bn254", "light-poseidon", @@ -2701,9 +2766,9 @@ dependencies = [ [[package]] name = "solana-precompile-error" -version = "2.1.0" +version = "2.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a30ab58b9e37cde4e5577282670f30df71b97b6b06dbdb420e9b84e57b831227" +checksum = "9ed911c6c1ec277b55cf5f082a893023a8a7a58b520823d9ef65f36ace939f2b" dependencies = [ "num-traits", "solana-decode-error", @@ -2711,16 +2776,16 @@ dependencies = [ [[package]] name = "solana-program" -version = "2.1.0" +version = "2.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9040decf2f295d35da22557eeab3768ab8dfca8aed9afe668663c8fa0e97d60e" +checksum = "fb05f5ffadb039285ee82efd9a593e0873220f840f0eac7069d962f9eb29a407" dependencies = [ "base64 0.22.1", "bincode", - "bitflags 2.6.0", + "bitflags 2.8.0", "blake3", "borsh 0.10.4", - "borsh 1.5.3", + "borsh 1.5.4", "bs58", "bv", "bytemuck", @@ -2776,6 +2841,7 @@ dependencies = [ "solana-slot-hashes", "solana-slot-history", "solana-stable-layout", + "solana-sysvar-id", "solana-transaction-error", "thiserror 1.0.69", "wasm-bindgen", @@ -2783,9 +2849,9 @@ dependencies = [ [[package]] name = "solana-program-entrypoint" -version = "2.1.0" +version = "2.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0eb90f3fa3e979b912451a404508f1f90bb6e5c1d7767625f622b20016fb9fde" +checksum = "c5f6148e740c6deed55fe343355f0cb3ec158d221e11aa8bb93a392fa62c4137" dependencies = [ "solana-account-info", "solana-msg", @@ -2795,11 +2861,11 @@ dependencies = [ [[package]] name = "solana-program-error" -version = "2.1.0" +version = "2.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd089caeef26dd07bd12b7b67d45e92faddc2fc67a960f316df7ae4776a2f3d5" +checksum = "d87e99e4299728f450194b6adf946dde512d79d82275b1c73f6faea7e9075cef" dependencies = [ - "borsh 1.5.3", + "borsh 1.5.4", "num-traits", "serde", "serde_derive", @@ -2811,9 +2877,9 @@ dependencies = [ [[package]] name = "solana-program-memory" -version = "2.1.0" +version = "2.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed4bc044dc2b49c323aeff04aec03c908a052e278c2edf2f7616f32fc0f1bcd9" +checksum = "3691cdd84c0a4753b484f468aac19e0943fab1e71705b21d00d561ac6eea6449" dependencies = [ "num-traits", "solana-define-syscall", @@ -2821,24 +2887,24 @@ dependencies = [ [[package]] name = "solana-program-option" -version = "2.1.0" +version = "2.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3babbdffd81994c043fc9a61458ce87496218825d6e9a303de643c0a53089b9a" +checksum = "e99a3e016363a95cdbe23aaa2a68578ffa2ce8e37c4a642962201af6376ffc37" [[package]] name = "solana-program-pack" -version = "2.1.0" +version = "2.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8fb28439d23e1f505e59c7a14ed5012365ab7aa0f20dc7bda048e02ff231cf6" +checksum = "4eba980dec9d5403ea299a3cdf27cd794e6b1a188acc8c5e3ae7d067b629eb24" dependencies = [ "solana-program-error", ] [[package]] name = "solana-program-runtime" -version = "2.1.0" +version = "2.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba1de51df173401d50c0f4cf750f5070d7a4c82125a03c1aec9622dc041b0b54" +checksum = "554db6e468732aa8b0a06a6d4f7b9aa87c9af3e230cec0de3d114d05ae562516" dependencies = [ "base64 0.22.1", "bincode", @@ -2866,12 +2932,12 @@ dependencies = [ [[package]] name = "solana-pubkey" -version = "2.1.0" +version = "2.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bea3215775fcedf200d47590c7e2ce9a3a46bc2b7d3f77d0eae9c6edf0a39aec" +checksum = "6dba2b19db8b73ab96b309b6d2a9f26386e45e2af3618a27b92389da9a3df1f1" dependencies = [ "borsh 0.10.4", - "borsh 1.5.3", + "borsh 1.5.4", "bs58", "bytemuck", "bytemuck_derive", @@ -2893,30 +2959,31 @@ dependencies = [ [[package]] name = "solana-rent" -version = "2.1.0" +version = "2.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aab3f4a270196c38d62c3bb3c7a2f07732af2c772b50da49c9b1e2c9d2ace286" +checksum = "138b60a6683d14d63b4cee532d50afcb54999679b5c53013969fd51977455e14" dependencies = [ "serde", "serde_derive", "solana-sdk-macro", + "solana-sysvar-id", ] [[package]] name = "solana-sanitize" -version = "2.1.0" +version = "2.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "203b90994371db8cade8e885f74ec9f68ee02a32b25d514594158b2551a4e5ed" +checksum = "58f71b885b953e9157b66eaba9a34507f2f840712ef54f483725ba510ee1bd89" [[package]] name = "solana-sdk" -version = "2.1.0" +version = "2.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "524604d94185c189616296e5b7da1014cc96d1e446bd2b26f247f00708b9225a" +checksum = "74a9bcaaedaf805d5541307e22b48ba80a5b0e2922c2d35ca7f23732efa6bd07" dependencies = [ "bincode", - "bitflags 2.6.0", - "borsh 1.5.3", + "bitflags 2.8.0", + "borsh 1.5.4", "bs58", "bytemuck", "bytemuck_derive", @@ -2963,6 +3030,7 @@ dependencies = [ "solana-sanitize", "solana-sdk-macro", "solana-secp256k1-recover", + "solana-secp256r1-program", "solana-serde-varint", "solana-short-vec", "solana-signature", @@ -2973,42 +3041,56 @@ dependencies = [ [[package]] name = "solana-sdk-macro" -version = "2.1.0" +version = "2.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bd2265b93dce9d3dcf9f395abf1a85b5e06e4da4aa60ca147620003ac3abc67" +checksum = "62f0b358f336ceac3827881915e5293f121c023cbd2150115046356c66898cb8" dependencies = [ "bs58", "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.96", ] [[package]] name = "solana-secp256k1-recover" -version = "2.1.0" +version = "2.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2eef5a00a75648273c3fb6e3d85b0c8c02fcc1e36c4271664dcc39b6b128d41" +checksum = "460c2e36586bcce843cdeaaf2364f3db7fbd9f266325e93d5e9af33f2605dd7d" dependencies = [ - "borsh 1.5.3", + "borsh 1.5.4", "libsecp256k1", "solana-define-syscall", "thiserror 1.0.69", ] +[[package]] +name = "solana-secp256r1-program" +version = "2.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a993ec6151c8f8ce77378a2506831c869b27ebdb0eaf65b375d38a4798c20d56" +dependencies = [ + "bytemuck", + "openssl", + "solana-feature-set", + "solana-instruction", + "solana-precompile-error", + "solana-pubkey", +] + [[package]] name = "solana-serde-varint" -version = "2.1.0" +version = "2.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9aeb51d3c20e2a61db0ef72617f3b8c9207a342a867af454a95f17add9f6c262" +checksum = "a98449030e53dcc2c4f160acab99b2bdb3e24ea8bff8ca6e71a6e539a54bf3d7" dependencies = [ "serde", ] [[package]] name = "solana-serialize-utils" -version = "2.1.0" +version = "2.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0cfb0b57c6a431fb15ff33053caadb6c36aed4e1ce74bea9adfc459a710b3626" +checksum = "d659aac218580fc3fb3e8350669db9bb01bc1bc849c90f0741cbfccb6663eb94" dependencies = [ "solana-instruction", "solana-pubkey", @@ -3017,9 +3099,9 @@ dependencies = [ [[package]] name = "solana-sha256-hasher" -version = "2.1.0" +version = "2.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd115f3a1136314b0183235080d29023530c3a0a5df60505fdb7ea620eff9fd6" +checksum = "0db90ad6643d4d626f923159eaa876000c09f8c2e9aa7ff59b803e8328712582" dependencies = [ "sha2 0.10.8", "solana-define-syscall", @@ -3028,18 +3110,18 @@ dependencies = [ [[package]] name = "solana-short-vec" -version = "2.1.0" +version = "2.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08e55330b694db1139dcdf2a1ea7781abe8bd994dec2ab29e36abfd06e4e9274" +checksum = "11f7de721a6c50cb3a41e027a623496be39e45c452fbf897f657cd1f2f67dbbd" dependencies = [ "serde", ] [[package]] name = "solana-signature" -version = "2.1.0" +version = "2.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ad9784d110f195a3a4fe423479d18f05b01a1c380a1430644a3b3038fdbe2f0" +checksum = "3123b0fba3a798cbb2091788c92880644464e56359abc7defed993c6efa88ef3" dependencies = [ "bs58", "ed25519-dalek", @@ -3052,31 +3134,33 @@ dependencies = [ [[package]] name = "solana-slot-hashes" -version = "2.1.0" +version = "2.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17d216c0ebf00e95acaf2b1e227e6cc900a5ce50fb81fa0743272851e88a788d" +checksum = "3840867aa6d0fac65d3a4c1f14fff650a8e148732a16c06ebd8a2389d79d4745" dependencies = [ "serde", "serde_derive", "solana-hash", + "solana-sysvar-id", ] [[package]] name = "solana-slot-history" -version = "2.1.0" +version = "2.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88cbcdf767891c6a40116a5ef8f7241000f074ece4ba80c8f00b4f62705fc8a4" +checksum = "101583a12fcce9b52f845b3c773f4ae6c3f4ca6a46177dadbd83e276baf82326" dependencies = [ "bv", "serde", "serde_derive", + "solana-sysvar-id", ] [[package]] name = "solana-stable-layout" -version = "2.1.0" +version = "2.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a5305ca88fb5deb219cd88f04e24f3a131769417d7fcb11a8da1126a8f98d23" +checksum = "9e1b923e1c9e42b6c98b1786ca003af6a0366932f08d63432e984fcc394b7b5e" dependencies = [ "solana-instruction", "solana-pubkey", @@ -3084,9 +3168,9 @@ dependencies = [ [[package]] name = "solana-system-program" -version = "2.1.0" +version = "2.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "242634cdc1eacaa83738cc100fdd583eb88f99cc2edcc900c8ebe57d77af51b1" +checksum = "7f37c7ac5c53f2a0c5222f24146ad8bf7ce84e96551997c05984264d5bdae1a9" dependencies = [ "bincode", "log", @@ -3098,11 +3182,20 @@ dependencies = [ "solana-type-overrides", ] +[[package]] +name = "solana-sysvar-id" +version = "2.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59351de877a7cf0cea0e436424ecf4ea0c08c59ff01ef0575436972b920b818c" +dependencies = [ + "solana-pubkey", +] + [[package]] name = "solana-timings" -version = "2.1.0" +version = "2.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8a8e2f926d488c1e2a65cbc05544dcb68cfa88deb4d50f89db5bfbda7ff2419" +checksum = "743bca35719b09d4d9abac84fce42a448d86eb62edc69404ce85077874469e46" dependencies = [ "eager", "enum-iterator", @@ -3111,9 +3204,9 @@ dependencies = [ [[package]] name = "solana-transaction-error" -version = "2.1.0" +version = "2.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37a4bea6d80b34fe6e785d19bf928fe103928d1f6c9935ec23bb6a9d4d7a33d2" +checksum = "1c3d2147cfaad2a5518b8e15621008699e28d32d6233cd7a6b27a506e01f1515" dependencies = [ "serde", "serde_derive", @@ -3123,9 +3216,9 @@ dependencies = [ [[package]] name = "solana-type-overrides" -version = "2.1.0" +version = "2.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2066f25d460d63801f91436c2640aaba4f2dc95aa18fe1e76f7f2c063e981d4e" +checksum = "b3cac7e7628c46bf5e243a4b0f11c0ad172a27cae2a5d97c7c6ca64fe9e6ece6" dependencies = [ "lazy_static", "rand 0.8.5", @@ -3133,9 +3226,9 @@ dependencies = [ [[package]] name = "solana-vote" -version = "2.1.0" +version = "2.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ab46788981765ee706094ca53ad8421aae0286a6b948e892fa7db88992a5373" +checksum = "490e9e84d72423b90f1adcc232051a4e3719bf3498508ea9ba9d15e967f4d327" dependencies = [ "itertools 0.12.1", "log", @@ -3184,7 +3277,7 @@ dependencies = [ "serial_test", "solana-program", "solana-sdk", - "thiserror 2.0.8", + "thiserror 2.0.11", ] [[package]] @@ -3218,9 +3311,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.90" +version = "2.0.96" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "919d3b74a5dd0ccd15aeb8f93e7006bd9e14c295087c9896a110f490752bcf31" +checksum = "d5d0adab1ae378d7f53bdebc67a39f1f151407ef230f0ce2883572f5d8985c80" dependencies = [ "proc-macro2", "quote", @@ -3241,7 +3334,7 @@ checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.96", ] [[package]] @@ -3267,12 +3360,13 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.14.0" +version = "3.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28cce251fcbc87fac86a866eeb0d6c2d536fc16d06f184bb61aeae11aa4cee0c" +checksum = "9a8a559c81686f576e8cd0290cd2a24a2a9ad80c98b3478856500fcbd7acd704" dependencies = [ "cfg-if", "fastrand", + "getrandom 0.2.15", "once_cell", "rustix", "windows-sys 0.59.0", @@ -3298,11 +3392,11 @@ dependencies = [ [[package]] name = "thiserror" -version = "2.0.8" +version = "2.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08f5383f3e0071702bf93ab5ee99b52d26936be9dedd9413067cbdcddcb6141a" +checksum = "d452f284b73e6d76dd36758a0c8684b1d5be31f92b89d07fd5822175732206fc" dependencies = [ - "thiserror-impl 2.0.8", + "thiserror-impl 2.0.11", ] [[package]] @@ -3313,18 +3407,18 @@ checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.96", ] [[package]] name = "thiserror-impl" -version = "2.0.8" +version = "2.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2f357fcec90b3caef6623a099691be676d033b40a058ac95d2a6ade6fa0c943" +checksum = "26afc1baea8a989337eeb52b6e72a039780ce45c3edfcc9c5b9d112feeb173c2" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.96", ] [[package]] @@ -3339,9 +3433,9 @@ dependencies = [ [[package]] name = "tinyvec" -version = "1.8.0" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "445e881f4f6d382d5f27c034e25eb92edd7c784ceab92a0937db7f2e9471b938" +checksum = "022db8904dfa342efe721985167e9fcd16c29b226db4397ed752a761cfce81e8" dependencies = [ "tinyvec_macros", ] @@ -3354,9 +3448,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.42.0" +version = "1.43.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cec9b21b0450273377fc97bd4c33a8acffc8c996c987a7c5b319a0083707551" +checksum = "3d61fa4ffa3de412bfea335c6ecff681de2b609ba3c77ef3e00e521813a9ed9e" dependencies = [ "backtrace", "bytes", @@ -3513,6 +3607,12 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + [[package]] name = "version_check" version = "0.9.5" @@ -3557,34 +3657,35 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.99" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a474f6281d1d70c17ae7aa6a613c87fce69a127e2624002df63dcb39d6cf6396" +checksum = "1edc8929d7499fc4e8f0be2262a241556cfc54a0bea223790e71446f2aab1ef5" dependencies = [ "cfg-if", "once_cell", + "rustversion", "wasm-bindgen-macro", ] [[package]] name = "wasm-bindgen-backend" -version = "0.2.99" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f89bb38646b4f81674e8f5c3fb81b562be1fd936d84320f3264486418519c79" +checksum = "2f0a0651a5c2bc21487bde11ee802ccaf4c51935d0d3d42a6101f98161700bc6" dependencies = [ "bumpalo", "log", "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.96", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-futures" -version = "0.4.49" +version = "0.4.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38176d9b44ea84e9184eff0bc34cc167ed044f816accfe5922e54d84cf48eca2" +checksum = "555d470ec0bc3bb57890405e5d4322cc9ea83cebb085523ced7be4144dac1e61" dependencies = [ "cfg-if", "js-sys", @@ -3595,9 +3696,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.99" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2cc6181fd9a7492eef6fef1f33961e3695e4579b9872a6f7c83aee556666d4fe" +checksum = "7fe63fc6d09ed3792bd0897b314f53de8e16568c2b3f7982f468c0bf9bd0b407" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -3605,28 +3706,31 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.99" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30d7a95b763d3c45903ed6c81f156801839e5ee968bb07e534c44df0fcd330c2" +checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.96", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.99" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "943aab3fdaaa029a6e0271b35ea10b72b943135afe9bffca82384098ad0e06a6" +checksum = "1a05d73b933a847d6cccdda8f838a22ff101ad9bf93e33684f39c1f5f0eece3d" +dependencies = [ + "unicode-ident", +] [[package]] name = "web-sys" -version = "0.3.76" +version = "0.3.77" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04dd7223427d52553d3702c004d3b2fe07c148165faa56313cb00211e31c12bc" +checksum = "33b6dd2ef9186f1f2072e409e99cd22a975331a6b3591b12c764e0e55c60d5d2" dependencies = [ "js-sys", "wasm-bindgen", @@ -3819,9 +3923,9 @@ checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winnow" -version = "0.6.20" +version = "0.6.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36c1fec1a2bb5866f07c25f68c26e565c4c200aebb96d7e55710c19d3e8ac49b" +checksum = "c8d71a593cc5c42ad7876e2c1fda56f314f3754c084128833e64f1345ff8a03a" dependencies = [ "memchr", ] @@ -3868,7 +3972,7 @@ checksum = "2380878cad4ac9aac1e2435f3eb4020e8374b5f13c296cb75b4620ff8e229154" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.96", "synstructure", ] @@ -3890,7 +3994,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.96", ] [[package]] @@ -3910,7 +4014,7 @@ checksum = "595eed982f7d355beb85837f651fa22e90b3c044842dc7f2c2842c086f295808" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.96", "synstructure", ] @@ -3931,7 +4035,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.96", ] [[package]] @@ -3953,5 +4057,5 @@ checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.90", + "syn 2.0.96", ] diff --git a/program/Cargo.toml b/program/Cargo.toml index 21b18ad..66123c2 100644 --- a/program/Cargo.toml +++ b/program/Cargo.toml @@ -22,7 +22,7 @@ thiserror = "2.0" [dev-dependencies] lazy_static = "1.5.0" -mollusk-svm = "0.0.13" +mollusk-svm = { version = "0.0.13", git = "https://github.com/buffalojoec/mollusk.git" } proptest = "1.5" serial_test = "3.2.0" solana-sdk = "2.1.0" diff --git a/program/tests/assert_instruction_count.rs b/program/tests/assert_instruction_count.rs index ab5de7c..0143a11 100644 --- a/program/tests/assert_instruction_count.rs +++ b/program/tests/assert_instruction_count.rs @@ -5,7 +5,7 @@ mod setup; use { mollusk_svm::{result::Check, Mollusk}, solana_sdk::{ - account::{AccountSharedData, ReadableAccount}, + account::{Account as SolanaAccount, ReadableAccount}, program_pack::Pack, pubkey::Pubkey, }, @@ -29,7 +29,7 @@ fn initialize_mint() { let mint_account = { let space = Mint::LEN; let lamports = mollusk.sysvars.rent.minimum_balance(space); - AccountSharedData::new(lamports, space, &id()) + SolanaAccount::new(lamports, space, &id()) }; mollusk.process_and_validate_instruction( @@ -61,7 +61,7 @@ fn initialize_account() { let token_account = { let space = Account::LEN; let lamports = mollusk.sysvars.rent.minimum_balance(space); - AccountSharedData::new(lamports, space, &id()) + SolanaAccount::new(lamports, space, &id()) }; mollusk.process_and_validate_instruction( @@ -69,7 +69,7 @@ fn initialize_account() { &[ (account, token_account), (mint, mint_account), - (owner, AccountSharedData::default()), + (owner, SolanaAccount::default()), mollusk.sysvars.keyed_account_for_rent_sysvar(), ], &[ @@ -99,7 +99,7 @@ fn mint_to() { &[ (mint, mint_account), (account, token_account), - (owner, AccountSharedData::default()), + (owner, SolanaAccount::default()), ], &[ Check::success(), @@ -133,7 +133,7 @@ fn transfer() { &[ (source, source_token_account), (destination, destination_token_account), - (owner, AccountSharedData::default()), + (owner, SolanaAccount::default()), ], &[ Check::success(), @@ -165,7 +165,7 @@ fn burn() { &[ (mint, mint_account), (account, token_account), - (owner, AccountSharedData::default()), + (owner, SolanaAccount::default()), ], &[ Check::success(), @@ -194,7 +194,7 @@ fn close_account() { &[ (mint, mint_account), (account, token_account), - (owner, AccountSharedData::default()), + (owner, SolanaAccount::default()), ], &[Check::success(), Check::account(&account).closed().build()], ); diff --git a/program/tests/close_account.rs b/program/tests/close_account.rs index 7cfbb06..cb1ac55 100644 --- a/program/tests/close_account.rs +++ b/program/tests/close_account.rs @@ -5,7 +5,7 @@ mod setup; use { mollusk_svm::{result::Check, Mollusk}, solana_sdk::{ - account::{AccountSharedData, ReadableAccount}, + account::{Account as SolanaAccount, ReadableAccount}, program_error::ProgramError, program_pack::Pack, pubkey::Pubkey, @@ -24,7 +24,7 @@ fn success_init_after_close_account() { let destination = Pubkey::new_unique(); let decimals = 9; - let owner_account = AccountSharedData::new(1_000_000_000, 0, &system_program::id()); + let owner_account = SolanaAccount::new(1_000_000_000, 0, &system_program::id()); let mint_account = setup::setup_mint_account(None, None, 0, decimals); let token_account = setup::setup_token_account(&mint, &owner, 0); @@ -32,36 +32,45 @@ fn success_init_after_close_account() { mollusk.process_and_validate_instruction_chain( &[ - instruction::close_account(&spl_token::id(), &account, &destination, &owner, &[]) - .unwrap(), - system_instruction::create_account( - &owner, - &account, - 1_000_000_000, - Account::LEN as u64, - &spl_token::id(), + ( + &instruction::close_account(&spl_token::id(), &account, &destination, &owner, &[]) + .unwrap(), + &[Check::success()], + ), + ( + &system_instruction::create_account( + &owner, + &account, + 1_000_000_000, + Account::LEN as u64, + &spl_token::id(), + ), + &[Check::success()], + ), + ( + &instruction::initialize_account(&spl_token::id(), &account, &mint, &owner) + .unwrap(), + &[ + Check::success(), + // Account successfully re-initialized. + Check::account(&account) + .data(setup::setup_token_account(&mint, &owner, 0).data()) + .owner(&spl_token::id()) + .build(), + // The destination should have the lamports from the closed account. + Check::account(&destination) + .lamports(expected_destination_lamports) + .build(), + ], ), - instruction::initialize_account(&spl_token::id(), &account, &mint, &owner).unwrap(), ], &[ (mint, mint_account), (account, token_account), (owner, owner_account), - (destination, AccountSharedData::default()), + (destination, SolanaAccount::default()), mollusk.sysvars.keyed_account_for_rent_sysvar(), ], - &[ - Check::success(), - // Account successfully re-initialized. - Check::account(&account) - .data(setup::setup_token_account(&mint, &owner, 0).data()) - .owner(&spl_token::id()) - .build(), - // The destination should have the lamports from the closed account. - Check::account(&destination) - .lamports(expected_destination_lamports) - .build(), - ], ); } @@ -75,7 +84,7 @@ fn fail_init_after_close_account() { let destination = Pubkey::new_unique(); let decimals = 9; - let owner_account = AccountSharedData::new(1_000_000_000, 0, &system_program::id()); + let owner_account = SolanaAccount::new(1_000_000_000, 0, &system_program::id()); let mint_account = setup::setup_mint_account(None, None, 0, decimals); let token_account = setup::setup_token_account(&mint, &owner, 0); @@ -83,29 +92,38 @@ fn fail_init_after_close_account() { mollusk.process_and_validate_instruction_chain( &[ - instruction::close_account(&spl_token::id(), &account, &destination, &owner, &[]) - .unwrap(), - system_instruction::transfer(&owner, &account, 1_000_000_000), - instruction::initialize_account(&spl_token::id(), &account, &mint, &owner).unwrap(), + ( + &instruction::close_account(&spl_token::id(), &account, &destination, &owner, &[]) + .unwrap(), + &[Check::success()], + ), + ( + &system_instruction::transfer(&owner, &account, 1_000_000_000), + &[Check::success()], + ), + ( + &instruction::initialize_account(&spl_token::id(), &account, &mint, &owner) + .unwrap(), + &[ + Check::err(ProgramError::InvalidAccountData), + // Account not re-initialized. + Check::account(&account) + .lamports(1_000_000_000) + .owner(&system_program::id()) + .build(), + // The destination should have the lamports from the closed account. + Check::account(&destination) + .lamports(expected_destination_lamports) + .build(), + ], + ), ], &[ (mint, mint_account), (account, token_account), (owner, owner_account), - (destination, AccountSharedData::default()), + (destination, SolanaAccount::default()), mollusk.sysvars.keyed_account_for_rent_sysvar(), ], - &[ - Check::err(ProgramError::InvalidAccountData), - // Account not re-initialized. - Check::account(&account) - .lamports(1_000_000_000) - .owner(&system_program::id()) - .build(), - // The destination should have the lamports from the closed account. - Check::account(&destination) - .lamports(expected_destination_lamports) - .build(), - ], ); } diff --git a/program/tests/processor.rs b/program/tests/processor.rs index 32e0779..1fd1edc 100644 --- a/program/tests/processor.rs +++ b/program/tests/processor.rs @@ -3,12 +3,10 @@ //! Program state processor tests use { - mollusk_svm::Mollusk, + mollusk_svm::{result::Check, Mollusk}, serial_test::serial, solana_sdk::{ - account::{ - create_account_for_test, Account as SolanaAccount, AccountSharedData, ReadableAccount, - }, + account::{create_account_for_test, Account as SolanaAccount, ReadableAccount}, account_info::{AccountInfo, IntoAccountInfo}, entrypoint::ProgramResult, instruction::Instruction, @@ -31,35 +29,25 @@ use { }, state::{Account, AccountState, Mint, Multisig}, }, - std::{ - collections::HashMap, - sync::{Arc, RwLock}, - }, + std::collections::HashMap, }; -lazy_static::lazy_static! { - static ref EXPECTED_DATA: Arc>> = Arc::new(RwLock::new(Vec::new())); -} - fn do_process_instruction( instruction: Instruction, mut accounts: Vec<&mut SolanaAccount>, + checks: &[Check], ) -> ProgramResult { // Prepare accounts for mollusk. - let instruction_accounts: Vec<(Pubkey, AccountSharedData)> = instruction + let instruction_accounts: Vec<(Pubkey, SolanaAccount)> = instruction .accounts .iter() .zip(&accounts) - .map(|(account_meta, account)| { - ( - account_meta.pubkey, - AccountSharedData::from((*account).clone()), - ) - }) + .map(|(account_meta, account)| (account_meta.pubkey, (*account).clone())) .collect(); let mollusk = Mollusk::new(&spl_token::ID, "spl_token"); - let result = mollusk.process_instruction(&instruction, &instruction_accounts); + let result = + mollusk.process_and_validate_instruction(&instruction, &instruction_accounts, checks); // Update accounts after the instruction is processed. for (original, (_, updated)) in accounts @@ -79,6 +67,7 @@ fn do_process_instruction( fn do_process_instruction_dups( instruction: Instruction, account_infos: Vec, + checks: &[Check], ) -> ProgramResult { let mut cached_accounts = HashMap::new(); let mut dedup_accounts = Vec::new(); @@ -93,21 +82,22 @@ fn do_process_instruction_dups( executable: account_info.executable, rent_epoch: account_info.rent_epoch, }; - dedup_accounts.push((*account_info.key, AccountSharedData::from(account))); + dedup_accounts.push((*account_info.key, account)); cached_accounts.insert(account_info.key, account_info); } }); let mollusk = Mollusk::new(&spl_token::ID, "spl_token"); - let result = mollusk.process_instruction(&instruction, &dedup_accounts); + let result = mollusk.process_and_validate_instruction(&instruction, &dedup_accounts, checks); // Update accounts after the instruction is processed. result .resulting_accounts .into_iter() .for_each(|(pubkey, account)| { + let account = account.clone(); let account_info = cached_accounts.get(&pubkey).unwrap(); - if account.data().is_empty() { + if account.data.is_empty() { // When the account is closed, the tests expect the data to // be zeroed. account_info.try_borrow_mut_data().unwrap().fill(0); @@ -126,10 +116,6 @@ fn do_process_instruction_dups( .map_err(|e| ProgramError::try_from(e).unwrap()) } -fn set_expected_data(expected_data: Vec) { - *EXPECTED_DATA.write().unwrap() = expected_data; -} - fn rent_sysvar() -> SolanaAccount { create_account_for_test(&Rent::default()) } @@ -162,7 +148,8 @@ fn test_initialize_mint() { Err(TokenError::NotRentExempt.into()), do_process_instruction( initialize_mint(&program_id, &mint_key, &owner_key, None, 2).unwrap(), - vec![&mut mint_account, &mut rent_sysvar] + vec![&mut mint_account, &mut rent_sysvar], + &[Check::err(TokenError::NotRentExempt.into())], ) ); @@ -172,6 +159,7 @@ fn test_initialize_mint() { do_process_instruction( initialize_mint(&program_id, &mint_key, &owner_key, None, 2).unwrap(), vec![&mut mint_account, &mut rent_sysvar], + &[Check::success()], ) .unwrap(); @@ -180,7 +168,8 @@ fn test_initialize_mint() { Err(TokenError::AlreadyInUse.into()), do_process_instruction( initialize_mint(&program_id, &mint_key, &owner_key, None, 2,).unwrap(), - vec![&mut mint_account, &mut rent_sysvar] + vec![&mut mint_account, &mut rent_sysvar], + &[Check::err(TokenError::AlreadyInUse.into())], ) ); @@ -188,6 +177,17 @@ fn test_initialize_mint() { do_process_instruction( initialize_mint(&program_id, &mint2_key, &owner_key, Some(&owner_key), 2).unwrap(), vec![&mut mint2_account, &mut rent_sysvar], + &[ + Check::success(), + // freeze authority is set + Check::account(&mint2_key) + .data_slice(46, &[1, 0, 0, 0]) + .build(), + // freeze authority matches owner + Check::account(&mint2_key) + .data_slice(50, owner_key.as_ref()) + .build(), + ], ) .unwrap(); let mint = Mint::unpack_unchecked(&mint2_account.data).unwrap(); @@ -209,7 +209,8 @@ fn test_initialize_mint2() { Err(TokenError::NotRentExempt.into()), do_process_instruction( initialize_mint2(&program_id, &mint_key, &owner_key, None, 2).unwrap(), - vec![&mut mint_account] + vec![&mut mint_account], + &[Check::err(TokenError::NotRentExempt.into())], ) ); @@ -219,6 +220,7 @@ fn test_initialize_mint2() { do_process_instruction( initialize_mint2(&program_id, &mint_key, &owner_key, None, 2).unwrap(), vec![&mut mint_account], + &[Check::success()], ) .unwrap(); @@ -227,7 +229,8 @@ fn test_initialize_mint2() { Err(TokenError::AlreadyInUse.into()), do_process_instruction( initialize_mint2(&program_id, &mint_key, &owner_key, None, 2,).unwrap(), - vec![&mut mint_account] + vec![&mut mint_account], + &[Check::err(TokenError::AlreadyInUse.into())], ) ); @@ -235,6 +238,17 @@ fn test_initialize_mint2() { do_process_instruction( initialize_mint2(&program_id, &mint2_key, &owner_key, Some(&owner_key), 2).unwrap(), vec![&mut mint2_account], + &[ + Check::success(), + // freeze authority is set + Check::account(&mint2_key) + .data_slice(46, &[1, 0, 0, 0]) + .build(), + // freeze authority matches owner + Check::account(&mint2_key) + .data_slice(50, owner_key.as_ref()) + .build(), + ], ) .unwrap(); let mint = Mint::unpack_unchecked(&mint2_account.data).unwrap(); @@ -264,6 +278,7 @@ fn test_initialize_mint_account() { &mut owner_account, &mut rent_sysvar ], + &[Check::err(TokenError::NotRentExempt.into())], ) ); @@ -280,6 +295,7 @@ fn test_initialize_mint_account() { &mut owner_account, &mut rent_sysvar ], + &[Check::err(TokenError::InvalidMint.into())], ) ); @@ -287,6 +303,7 @@ fn test_initialize_mint_account() { do_process_instruction( initialize_mint(&program_id, &mint_key, &owner_key, None, 2).unwrap(), vec![&mut mint_account, &mut rent_sysvar], + &[Check::success()], ) .unwrap(); @@ -303,6 +320,7 @@ fn test_initialize_mint_account() { &mut owner_account, &mut rent_sysvar ], + &[Check::err(ProgramError::IncorrectProgramId)], ) ); mint_account.owner = program_id; @@ -316,6 +334,7 @@ fn test_initialize_mint_account() { &mut owner_account, &mut rent_sysvar, ], + &[Check::success()], ) .unwrap(); @@ -330,6 +349,7 @@ fn test_initialize_mint_account() { &mut owner_account, &mut rent_sysvar ], + &[Check::err(TokenError::AlreadyInUse.into())], ) ); } @@ -387,6 +407,7 @@ fn test_transfer_dups() { do_process_instruction_dups( initialize_mint(&program_id, &mint_key, &owner_key, None, 2).unwrap(), vec![mint_info.clone(), rent_info.clone()], + &[Check::success()], ) .unwrap(); @@ -399,6 +420,7 @@ fn test_transfer_dups() { account1_info.clone(), rent_info.clone(), ], + &[Check::success()], ) .unwrap(); @@ -411,6 +433,7 @@ fn test_transfer_dups() { owner_info.clone(), rent_info.clone(), ], + &[Check::success()], ) .unwrap(); @@ -418,6 +441,7 @@ fn test_transfer_dups() { do_process_instruction_dups( mint_to(&program_id, &mint_key, &account1_key, &owner_key, &[], 1000).unwrap(), vec![mint_info.clone(), account1_info.clone(), owner_info.clone()], + &[Check::success()], ) .unwrap(); @@ -437,6 +461,7 @@ fn test_transfer_dups() { account2_info.clone(), account1_info.clone(), ], + &[Check::success()], ) .unwrap(); @@ -459,6 +484,7 @@ fn test_transfer_dups() { account2_info.clone(), account1_info.clone(), ], + &[Check::success()], ) .unwrap(); @@ -485,6 +511,7 @@ fn test_transfer_dups() { account2_info.clone(), account1_info.clone(), ], + &[Check::success()], ) .unwrap(); @@ -507,6 +534,7 @@ fn test_transfer_dups() { account2_info.clone(), account1_info.clone(), ], + &[Check::success()], ) .unwrap(); @@ -519,11 +547,13 @@ fn test_transfer_dups() { account2_info.clone(), rent_info.clone(), ], + &[Check::success()], ) .unwrap(); do_process_instruction_dups( mint_to(&program_id, &mint_key, &account3_key, &owner_key, &[], 1000).unwrap(), vec![mint_info.clone(), account3_info.clone(), owner_info.clone()], + &[Check::success()], ) .unwrap(); @@ -544,6 +574,7 @@ fn test_transfer_dups() { account2_info.clone(), account2_info.clone(), ], + &[Check::success()], ) .unwrap(); @@ -566,6 +597,7 @@ fn test_transfer_dups() { account2_info.clone(), account2_info.clone(), ], + &[Check::success()], ) .unwrap(); @@ -577,6 +609,7 @@ fn test_transfer_dups() { rent_info.clone(), account4_info.clone(), ], + &[Check::success()], ) .unwrap(); @@ -588,12 +621,14 @@ fn test_transfer_dups() { multisig_info.clone(), rent_info.clone(), ], + &[Check::success()], ) .unwrap(); do_process_instruction_dups( mint_to(&program_id, &mint_key, &account4_key, &owner_key, &[], 1000).unwrap(), vec![mint_info.clone(), account4_info.clone(), owner_info.clone()], + &[Check::success()], ) .unwrap(); @@ -614,6 +649,7 @@ fn test_transfer_dups() { multisig_info.clone(), account4_info.clone(), ], + &[Check::success()], ) .unwrap(); @@ -637,6 +673,7 @@ fn test_transfer_dups() { multisig_info.clone(), account4_info.clone(), ], + &[Check::success()], ) .unwrap(); } @@ -684,6 +721,7 @@ fn test_transfer() { do_process_instruction( initialize_mint(&program_id, &mint_key, &owner_key, None, 2).unwrap(), vec![&mut mint_account, &mut rent_sysvar], + &[Check::success()], ) .unwrap(); @@ -696,6 +734,7 @@ fn test_transfer() { &mut owner_account, &mut rent_sysvar, ], + &[Check::success()], ) .unwrap(); @@ -708,6 +747,7 @@ fn test_transfer() { &mut owner_account, &mut rent_sysvar, ], + &[Check::success()], ) .unwrap(); @@ -720,6 +760,7 @@ fn test_transfer() { &mut owner_account, &mut rent_sysvar, ], + &[Check::success()], ) .unwrap(); @@ -732,6 +773,7 @@ fn test_transfer() { &mut owner_account, &mut rent_sysvar, ], + &[Check::success()], ) .unwrap(); let mut account = Account::unpack_unchecked(&mismatch_account.data).unwrap(); @@ -742,6 +784,7 @@ fn test_transfer() { do_process_instruction( mint_to(&program_id, &mint_key, &account_key, &owner_key, &[], 1000).unwrap(), vec![&mut mint_account, &mut account_account, &mut owner_account], + &[Check::success()], ) .unwrap(); @@ -765,6 +808,7 @@ fn test_transfer() { &mut account2_account, &mut owner_account, ], + &[Check::err(ProgramError::MissingRequiredSignature)], ) ); @@ -786,6 +830,7 @@ fn test_transfer() { &mut mismatch_account, &mut owner_account, ], + &[Check::err(TokenError::MintMismatch.into())], ) ); @@ -807,6 +852,7 @@ fn test_transfer() { &mut account2_account, &mut owner2_account, ], + &[Check::err(TokenError::OwnerMismatch.into())], ) ); @@ -822,6 +868,7 @@ fn test_transfer() { &mut account2_account, &mut owner2_account, ], + &[Check::err(ProgramError::IncorrectProgramId)], ) ); account_account.owner = program_id; @@ -838,6 +885,7 @@ fn test_transfer() { &mut account2_account, &mut owner2_account, ], + &[Check::err(ProgramError::IncorrectProgramId)], ) ); account2_account.owner = program_id; @@ -858,6 +906,7 @@ fn test_transfer() { &mut account2_account, &mut owner_account, ], + &[Check::success()], ) .unwrap(); @@ -871,6 +920,7 @@ fn test_transfer() { &mut account2_account, &mut owner_account, ], + &[Check::err(TokenError::InsufficientFunds.into())], ) ); @@ -890,6 +940,7 @@ fn test_transfer() { &mut account_account, &mut owner_account, ], + &[Check::success()], ) .unwrap(); @@ -914,6 +965,7 @@ fn test_transfer() { &mut account_account, &mut owner_account, ], + &[Check::err(TokenError::MintDecimalsMismatch.into())], ) ); @@ -938,6 +990,7 @@ fn test_transfer() { &mut account_account, &mut owner_account, ], + &[Check::err(TokenError::MintMismatch.into())], ) ); // transfer rest with explicit decimals @@ -959,6 +1012,7 @@ fn test_transfer() { &mut account_account, &mut owner_account, ], + &[Check::success()], ) .unwrap(); @@ -972,6 +1026,7 @@ fn test_transfer() { &mut account_account, &mut owner_account, ], + &[Check::err(TokenError::InsufficientFunds.into())], ) ); @@ -991,6 +1046,7 @@ fn test_transfer() { &mut delegate_account, &mut owner_account, ], + &[Check::success()], ) .unwrap(); @@ -1012,6 +1068,7 @@ fn test_transfer() { &mut account2_account, &mut owner2_account, ], + &[Check::err(TokenError::OwnerMismatch.into())], ) ); @@ -1033,6 +1090,7 @@ fn test_transfer() { &mut account2_account, &mut delegate_account, ], + &[Check::err(TokenError::InsufficientFunds.into())], ) ); @@ -1052,6 +1110,7 @@ fn test_transfer() { &mut account2_account, &mut delegate_account, ], + &[Check::success()], ) .unwrap(); @@ -1073,6 +1132,7 @@ fn test_transfer() { &mut account2_account, &mut delegate_account, ], + &[Check::err(TokenError::OwnerMismatch.into())], ) ); @@ -1092,6 +1152,7 @@ fn test_transfer() { &mut account2_account, &mut owner_account, ], + &[Check::success()], ) .unwrap(); @@ -1111,6 +1172,7 @@ fn test_transfer() { &mut delegate_account, &mut owner_account, ], + &[Check::success()], ) .unwrap(); @@ -1132,6 +1194,7 @@ fn test_transfer() { &mut account2_account, &mut delegate_account, ], + &[Check::err(TokenError::InsufficientFunds.into())], ) ); } @@ -1172,6 +1235,7 @@ fn test_self_transfer() { do_process_instruction( initialize_mint(&program_id, &mint_key, &owner_key, None, 2).unwrap(), vec![&mut mint_account, &mut rent_sysvar], + &[Check::success()], ) .unwrap(); @@ -1184,6 +1248,7 @@ fn test_self_transfer() { &mut owner_account, &mut rent_sysvar, ], + &[Check::success()], ) .unwrap(); @@ -1196,6 +1261,7 @@ fn test_self_transfer() { &mut owner_account, &mut rent_sysvar, ], + &[Check::success()], ) .unwrap(); @@ -1208,6 +1274,7 @@ fn test_self_transfer() { &mut owner_account, &mut rent_sysvar, ], + &[Check::success()], ) .unwrap(); @@ -1215,6 +1282,7 @@ fn test_self_transfer() { do_process_instruction( mint_to(&program_id, &mint_key, &account_key, &owner_key, &[], 1000).unwrap(), vec![&mut mint_account, &mut account_account, &mut owner_account], + &[Check::success()], ) .unwrap(); @@ -1244,6 +1312,12 @@ fn test_self_transfer() { account_info.clone(), owner_info.clone(), ], + &[ + Check::success(), + Check::account(account_info.key) + .data_slice(64, &1000u64.to_le_bytes()) + .build() + ], ) ); // no balance change... @@ -1272,6 +1346,12 @@ fn test_self_transfer() { account_info.clone(), owner_info.clone(), ], + &[ + Check::success(), + Check::account(account_info.key) + .data_slice(64, &1000u64.to_le_bytes()) + .build() + ], ) ); // no balance change... @@ -1300,6 +1380,7 @@ fn test_self_transfer() { account_info.clone(), owner_no_sign_info.clone(), ], + &[Check::err(ProgramError::MissingRequiredSignature)], ) ); @@ -1326,6 +1407,7 @@ fn test_self_transfer() { account_info.clone(), owner_no_sign_info, ], + &[Check::err(ProgramError::MissingRequiredSignature)], ) ); @@ -1348,6 +1430,7 @@ fn test_self_transfer() { account_info.clone(), owner2_info.clone(), ], + &[Check::err(TokenError::OwnerMismatch.into())], ) ); @@ -1373,6 +1456,7 @@ fn test_self_transfer() { account_info.clone(), owner2_info.clone(), ], + &[Check::err(TokenError::OwnerMismatch.into())], ) ); @@ -1395,6 +1479,7 @@ fn test_self_transfer() { account_info.clone(), owner_info.clone(), ], + &[Check::err(TokenError::InsufficientFunds.into())], ) ); @@ -1420,6 +1505,7 @@ fn test_self_transfer() { account_info.clone(), owner_info.clone(), ], + &[Check::err(TokenError::InsufficientFunds.into())], ) ); @@ -1445,6 +1531,7 @@ fn test_self_transfer() { account_info.clone(), owner_info.clone(), ], + &[Check::err(TokenError::MintDecimalsMismatch.into())], ) ); @@ -1470,6 +1557,7 @@ fn test_self_transfer() { account_info.clone(), owner_info.clone(), ], + &[Check::err(TokenError::MintMismatch.into())], ) ); @@ -1490,6 +1578,7 @@ fn test_self_transfer() { delegate_info.clone(), owner_info.clone(), ], + &[Check::success()], ) .unwrap(); @@ -1512,6 +1601,15 @@ fn test_self_transfer() { account_info.clone(), delegate_info.clone(), ], + &[ + Check::success(), + Check::account(account_info.key) + .data_slice(64, &1000u64.to_le_bytes()) + .build(), + Check::account(&account_key) + .data_slice(121, &100u64.to_le_bytes()) + .build(), + ], ) ); // no balance change... @@ -1541,6 +1639,15 @@ fn test_self_transfer() { account_info.clone(), delegate_info.clone(), ], + &[ + Check::success(), + Check::account(account_info.key) + .data_slice(64, &1000u64.to_le_bytes()) + .build(), + Check::account(&account_key) + .data_slice(121, &100u64.to_le_bytes()) + .build(), + ], ) ); // no balance change... @@ -1567,6 +1674,7 @@ fn test_self_transfer() { account_info.clone(), delegate_info.clone(), ], + &[Check::err(TokenError::InsufficientFunds.into())], ) ); @@ -1592,6 +1700,7 @@ fn test_self_transfer() { account_info.clone(), delegate_info.clone(), ], + &[Check::err(TokenError::InsufficientFunds.into())], ) ); @@ -1614,6 +1723,12 @@ fn test_self_transfer() { account_info.clone(), owner_info.clone(), ], + &[ + Check::success(), + Check::account(account_info.key) + .data_slice(64, &1000u64.to_le_bytes()) + .build(), + ], ) ); // no balance change... @@ -1642,6 +1757,12 @@ fn test_self_transfer() { account_info.clone(), owner_info.clone(), ], + &[ + Check::success(), + Check::account(account_info.key) + .data_slice(64, &1000u64.to_le_bytes()) + .build(), + ], ) ); // no balance change... @@ -1667,22 +1788,26 @@ fn test_mintable_token_with_zero_supply() { // create mint-able token with zero supply let decimals = 2; + let expected_mint = Mint { + mint_authority: COption::Some(owner_key), + supply: 0, + decimals, + is_initialized: true, + freeze_authority: COption::None, + }; + let mut mint_data = [0u8; Mint::LEN]; + expected_mint.pack_into_slice(&mut mint_data); do_process_instruction( initialize_mint(&program_id, &mint_key, &owner_key, None, decimals).unwrap(), vec![&mut mint_account, &mut rent_sysvar], + &[ + Check::success(), + Check::account(&mint_key).data(&mint_data).build(), + ], ) .unwrap(); let mint = Mint::unpack_unchecked(&mint_account.data).unwrap(); - assert_eq!( - mint, - Mint { - mint_authority: COption::Some(owner_key), - supply: 0, - decimals, - is_initialized: true, - freeze_authority: COption::None, - } - ); + assert_eq!(mint, expected_mint); // create account do_process_instruction( @@ -1693,6 +1818,7 @@ fn test_mintable_token_with_zero_supply() { &mut owner_account, &mut rent_sysvar, ], + &[Check::success()], ) .unwrap(); @@ -1700,6 +1826,12 @@ fn test_mintable_token_with_zero_supply() { do_process_instruction( mint_to(&program_id, &mint_key, &account_key, &owner_key, &[], 42).unwrap(), vec![&mut mint_account, &mut account_account, &mut owner_account], + &[ + Check::success(), + Check::account(&account_key) + .data_slice(64, &42u64.to_le_bytes()) + .build(), + ], ) .unwrap(); let _ = Mint::unpack(&mint_account.data).unwrap(); @@ -1721,6 +1853,12 @@ fn test_mintable_token_with_zero_supply() { ) .unwrap(), vec![&mut mint_account, &mut account_account, &mut owner_account], + &[ + Check::err(TokenError::MintDecimalsMismatch.into()), + Check::account(&account_key) + .data_slice(64, &42u64.to_le_bytes()) + .build(), + ], ) ); @@ -1741,6 +1879,12 @@ fn test_mintable_token_with_zero_supply() { ) .unwrap(), vec![&mut mint_account, &mut account_account, &mut owner_account], + &[ + Check::success(), + Check::account(&account_key) + .data_slice(64, &84u64.to_le_bytes()) + .build(), + ], ) .unwrap(); let _ = Mint::unpack(&mint_account.data).unwrap(); @@ -1794,6 +1938,7 @@ fn test_approve_dups() { do_process_instruction_dups( initialize_mint(&program_id, &mint_key, &owner_key, None, 2).unwrap(), vec![mint_info.clone(), rent_info.clone()], + &[Check::success()], ) .unwrap(); @@ -1806,6 +1951,7 @@ fn test_approve_dups() { account1_info.clone(), rent_info.clone(), ], + &[Check::success()], ) .unwrap(); @@ -1818,6 +1964,7 @@ fn test_approve_dups() { owner_info.clone(), rent_info.clone(), ], + &[Check::success()], ) .unwrap(); @@ -1825,6 +1972,7 @@ fn test_approve_dups() { do_process_instruction_dups( mint_to(&program_id, &mint_key, &account1_key, &owner_key, &[], 1000).unwrap(), vec![mint_info.clone(), account1_info.clone(), owner_info.clone()], + &[Check::success()], ) .unwrap(); @@ -1844,6 +1992,7 @@ fn test_approve_dups() { account2_info.clone(), account1_info.clone(), ], + &[Check::success()], ) .unwrap(); @@ -1866,6 +2015,7 @@ fn test_approve_dups() { account2_info.clone(), account1_info.clone(), ], + &[Check::success()], ) .unwrap(); @@ -1873,6 +2023,7 @@ fn test_approve_dups() { do_process_instruction_dups( revoke(&program_id, &account1_key, &account1_key, &[]).unwrap(), vec![account1_info.clone(), account1_info.clone()], + &[Check::success()], ) .unwrap(); @@ -1884,6 +2035,7 @@ fn test_approve_dups() { rent_info.clone(), account3_info.clone(), ], + &[Check::success()], ) .unwrap(); @@ -1895,12 +2047,14 @@ fn test_approve_dups() { multisig_info.clone(), rent_info.clone(), ], + &[Check::success()], ) .unwrap(); do_process_instruction_dups( mint_to(&program_id, &mint_key, &account3_key, &owner_key, &[], 1000).unwrap(), vec![mint_info.clone(), account3_info.clone(), owner_info.clone()], + &[Check::success()], ) .unwrap(); @@ -1921,6 +2075,7 @@ fn test_approve_dups() { multisig_info.clone(), account3_info.clone(), ], + &[Check::success()], ) .unwrap(); @@ -1944,6 +2099,7 @@ fn test_approve_dups() { multisig_info.clone(), account3_info.clone(), ], + &[Check::success()], ) .unwrap(); @@ -1955,6 +2111,7 @@ fn test_approve_dups() { multisig_info.clone(), account3_info.clone(), ], + &[Check::success()], ) .unwrap(); } @@ -1989,6 +2146,7 @@ fn test_approve() { do_process_instruction( initialize_mint(&program_id, &mint_key, &owner_key, None, 2).unwrap(), vec![&mut mint_account, &mut rent_sysvar], + &[Check::success()], ) .unwrap(); @@ -2001,6 +2159,7 @@ fn test_approve() { &mut owner_account, &mut rent_sysvar, ], + &[Check::success()], ) .unwrap(); @@ -2013,6 +2172,7 @@ fn test_approve() { &mut owner_account, &mut rent_sysvar, ], + &[Check::success()], ) .unwrap(); @@ -2020,6 +2180,7 @@ fn test_approve() { do_process_instruction( mint_to(&program_id, &mint_key, &account_key, &owner_key, &[], 1000).unwrap(), vec![&mut mint_account, &mut account_account, &mut owner_account], + &[Check::success()], ) .unwrap(); @@ -2043,6 +2204,7 @@ fn test_approve() { &mut delegate_account, &mut owner_account, ], + &[Check::err(ProgramError::MissingRequiredSignature)], ) ); @@ -2064,6 +2226,7 @@ fn test_approve() { &mut delegate_account, &mut owner2_account, ], + &[Check::err(TokenError::OwnerMismatch.into())], ) ); @@ -2083,6 +2246,7 @@ fn test_approve() { &mut delegate_account, &mut owner_account, ], + &[Check::success()], ) .unwrap(); @@ -2107,6 +2271,7 @@ fn test_approve() { &mut delegate_account, &mut owner_account, ], + &[Check::err(TokenError::MintDecimalsMismatch.into())], ) ); @@ -2131,6 +2296,7 @@ fn test_approve() { &mut delegate_account, &mut owner_account, ], + &[Check::err(TokenError::MintMismatch.into())], ) ); @@ -2153,6 +2319,7 @@ fn test_approve() { &mut delegate_account, &mut owner_account, ], + &[Check::success()], ) .unwrap(); @@ -2160,6 +2327,7 @@ fn test_approve() { do_process_instruction( revoke(&program_id, &account_key, &owner_key, &[]).unwrap(), vec![&mut account_account, &mut owner_account], + &[Check::success()], ) .unwrap(); } @@ -2187,6 +2355,7 @@ fn test_set_authority_dups() { do_process_instruction_dups( initialize_mint(&program_id, &mint_key, &mint_key, Some(&mint_key), 2).unwrap(), vec![mint_info.clone(), rent_info.clone()], + &[Check::success()], ) .unwrap(); @@ -2199,6 +2368,7 @@ fn test_set_authority_dups() { account1_info.clone(), rent_info.clone(), ], + &[Check::success()], ) .unwrap(); @@ -2214,6 +2384,7 @@ fn test_set_authority_dups() { ) .unwrap(), vec![mint_info.clone(), mint_info.clone()], + &[Check::success()], ) .unwrap(); @@ -2229,6 +2400,7 @@ fn test_set_authority_dups() { ) .unwrap(), vec![mint_info.clone(), mint_info.clone()], + &[Check::success()], ) .unwrap(); @@ -2244,6 +2416,7 @@ fn test_set_authority_dups() { ) .unwrap(), vec![account1_info.clone(), account1_info.clone()], + &[Check::success()], ) .unwrap(); @@ -2263,6 +2436,7 @@ fn test_set_authority_dups() { ) .unwrap(), vec![account1_info.clone(), account1_info.clone()], + &[Check::success()], ) .unwrap(); } @@ -2300,6 +2474,7 @@ fn test_set_authority() { do_process_instruction( initialize_mint(&program_id, &mint_key, &owner_key, None, 2).unwrap(), vec![&mut mint_account, &mut rent_sysvar], + &[Check::success()], ) .unwrap(); @@ -2307,6 +2482,7 @@ fn test_set_authority() { do_process_instruction( initialize_mint(&program_id, &mint2_key, &owner_key, Some(&owner_key), 2).unwrap(), vec![&mut mint2_account, &mut rent_sysvar], + &[Check::success()], ) .unwrap(); @@ -2324,6 +2500,7 @@ fn test_set_authority() { ) .unwrap(), vec![&mut account_account, &mut owner_account], + &[Check::err(ProgramError::UninitializedAccount)], ) ); @@ -2336,6 +2513,7 @@ fn test_set_authority() { &mut owner_account, &mut rent_sysvar, ], + &[Check::success()], ) .unwrap(); @@ -2348,6 +2526,7 @@ fn test_set_authority() { &mut owner_account, &mut rent_sysvar, ], + &[Check::success()], ) .unwrap(); @@ -2365,6 +2544,7 @@ fn test_set_authority() { ) .unwrap(), vec![&mut account_account, &mut owner2_account], + &[Check::err(TokenError::OwnerMismatch.into())], ) ); @@ -2381,7 +2561,11 @@ fn test_set_authority() { instruction.accounts[1].is_signer = false; assert_eq!( Err(ProgramError::MissingRequiredSignature), - do_process_instruction(instruction, vec![&mut account_account, &mut owner_account,],) + do_process_instruction( + instruction, + vec![&mut account_account, &mut owner_account,], + &[Check::err(ProgramError::MissingRequiredSignature)] + ), ); // wrong authority type @@ -2398,6 +2582,7 @@ fn test_set_authority() { ) .unwrap(), vec![&mut account_account, &mut owner_account], + &[Check::err(TokenError::AuthorityTypeNotSupported.into())], ) ); @@ -2415,6 +2600,7 @@ fn test_set_authority() { ) .unwrap(), vec![&mut account_account, &mut owner_account], + &[Check::err(TokenError::InvalidInstruction.into())], ) ); @@ -2434,6 +2620,21 @@ fn test_set_authority() { &mut owner2_account, &mut owner_account, ], + &[ + Check::success(), + // delegate set + Check::account(&account_key) + .data_slice(72, &[1, 0, 0, 0]) + .build(), + // delegate + Check::account(&account_key) + .data_slice(76, owner2_key.as_ref()) + .build(), + // delegated amount + Check::account(&account_key) + .data_slice(121, &u64::MAX.to_le_bytes()) + .build(), + ], ) .unwrap(); let account = Account::unpack_unchecked(&account_account.data).unwrap(); @@ -2452,6 +2653,17 @@ fn test_set_authority() { ) .unwrap(), vec![&mut account_account, &mut owner_account], + &[ + Check::success(), + // delegate not set + Check::account(&account_key) + .data_slice(72, &[0, 0, 0, 0]) + .build(), + // delegated amount + Check::account(&account_key) + .data_slice(121, &0u64.to_le_bytes()) + .build(), + ], ) .unwrap(); @@ -2472,6 +2684,7 @@ fn test_set_authority() { ) .unwrap(), vec![&mut account_account, &mut owner3_account], + &[Check::success()], ) .unwrap(); @@ -2487,6 +2700,7 @@ fn test_set_authority() { ) .unwrap(), vec![&mut account_account, &mut owner2_account], + &[Check::success()], ) .unwrap(); @@ -2502,6 +2716,7 @@ fn test_set_authority() { ) .unwrap(), vec![&mut account_account, &mut owner2_account], + &[Check::success()], ) .unwrap(); @@ -2519,6 +2734,7 @@ fn test_set_authority() { ) .unwrap(), vec![&mut mint_account, &mut owner2_account], + &[Check::err(TokenError::OwnerMismatch.into())], ) ); @@ -2535,7 +2751,11 @@ fn test_set_authority() { instruction.accounts[1].is_signer = false; assert_eq!( Err(ProgramError::MissingRequiredSignature), - do_process_instruction(instruction, vec![&mut mint_account, &mut owner_account],) + do_process_instruction( + instruction, + vec![&mut mint_account, &mut owner_account], + &[Check::err(ProgramError::MissingRequiredSignature)] + ), ); // cannot freeze @@ -2552,6 +2772,7 @@ fn test_set_authority() { ) .unwrap(), vec![&mut mint_account, &mut owner_account], + &[Check::err(TokenError::MintCannotFreeze.into())], ) ); @@ -2567,6 +2788,7 @@ fn test_set_authority() { ) .unwrap(), vec![&mut mint_account, &mut owner_account], + &[Check::success()], ) .unwrap(); @@ -2582,6 +2804,7 @@ fn test_set_authority() { ) .unwrap(), vec![&mut mint_account, &mut owner2_account], + &[Check::success()], ) .unwrap(); @@ -2599,6 +2822,7 @@ fn test_set_authority() { ) .unwrap(), vec![&mut mint_account, &mut owner_account], + &[Check::err(TokenError::FixedSupply.into())], ) ); @@ -2614,6 +2838,7 @@ fn test_set_authority() { ) .unwrap(), vec![&mut mint2_account, &mut owner_account], + &[Check::success()], ) .unwrap(); @@ -2629,6 +2854,7 @@ fn test_set_authority() { ) .unwrap(), vec![&mut mint2_account, &mut owner2_account], + &[Check::success()], ) .unwrap(); @@ -2645,6 +2871,7 @@ fn test_set_authority() { ) .unwrap(), vec![&mut mint2_account, &mut owner2_account], + &[Check::err(TokenError::MintCannotFreeze.into())], ) ); } @@ -2674,6 +2901,7 @@ fn test_mint_to_dups() { do_process_instruction_dups( initialize_mint(&program_id, &mint_key, &mint_key, None, 2).unwrap(), vec![mint_info.clone(), rent_info.clone()], + &[Check::success()], ) .unwrap(); @@ -2686,6 +2914,7 @@ fn test_mint_to_dups() { owner_info.clone(), rent_info.clone(), ], + &[Check::success()], ) .unwrap(); @@ -2693,6 +2922,7 @@ fn test_mint_to_dups() { do_process_instruction_dups( mint_to(&program_id, &mint_key, &account1_key, &mint_key, &[], 42).unwrap(), vec![mint_info.clone(), account1_info.clone(), mint_info.clone()], + &[Check::success()], ) .unwrap(); @@ -2700,6 +2930,7 @@ fn test_mint_to_dups() { do_process_instruction_dups( mint_to_checked(&program_id, &mint_key, &account1_key, &mint_key, &[], 42, 2).unwrap(), vec![mint_info.clone(), account1_info.clone(), mint_info.clone()], + &[Check::success()], ) .unwrap(); @@ -2722,6 +2953,7 @@ fn test_mint_to_dups() { account1_info.clone(), account1_info.clone(), ], + &[Check::success()], ) .unwrap(); @@ -2741,6 +2973,7 @@ fn test_mint_to_dups() { account1_info.clone(), account1_info.clone(), ], + &[Check::success()], ) .unwrap(); } @@ -2792,6 +3025,7 @@ fn test_mint_to() { do_process_instruction( initialize_mint(&program_id, &mint_key, &owner_key, None, 2).unwrap(), vec![&mut mint_account, &mut rent_sysvar], + &[Check::success()], ) .unwrap(); @@ -2804,6 +3038,7 @@ fn test_mint_to() { &mut owner_account, &mut rent_sysvar, ], + &[Check::success()], ) .unwrap(); @@ -2816,6 +3051,7 @@ fn test_mint_to() { &mut owner_account, &mut rent_sysvar, ], + &[Check::success()], ) .unwrap(); @@ -2828,6 +3064,7 @@ fn test_mint_to() { &mut owner_account, &mut rent_sysvar, ], + &[Check::success()], ) .unwrap(); @@ -2840,6 +3077,7 @@ fn test_mint_to() { &mut owner_account, &mut rent_sysvar, ], + &[Check::success()], ) .unwrap(); let mut account = Account::unpack_unchecked(&mismatch_account.data).unwrap(); @@ -2850,6 +3088,15 @@ fn test_mint_to() { do_process_instruction( mint_to(&program_id, &mint_key, &account_key, &owner_key, &[], 42).unwrap(), vec![&mut mint_account, &mut account_account, &mut owner_account], + &[ + Check::success(), + Check::account(&mint_key) + .data_slice(36, &42u64.to_le_bytes()) + .build(), + Check::account(&account_key) + .data_slice(64, &42u64.to_le_bytes()) + .build(), + ], ) .unwrap(); @@ -2862,6 +3109,15 @@ fn test_mint_to() { do_process_instruction( mint_to(&program_id, &mint_key, &account2_key, &owner_key, &[], 42).unwrap(), vec![&mut mint_account, &mut account2_account, &mut owner_account], + &[ + Check::success(), + Check::account(&mint_key) + .data_slice(36, &84u64.to_le_bytes()) + .build(), + Check::account(&account2_key) + .data_slice(64, &42u64.to_le_bytes()) + .build(), + ], ) .unwrap(); @@ -2879,6 +3135,7 @@ fn test_mint_to() { do_process_instruction( instruction, vec![&mut mint_account, &mut account2_account, &mut owner_account], + &[Check::err(ProgramError::MissingRequiredSignature)], ) ); @@ -2888,6 +3145,7 @@ fn test_mint_to() { do_process_instruction( mint_to(&program_id, &mint_key, &mismatch_key, &owner_key, &[], 42).unwrap(), vec![&mut mint_account, &mut mismatch_account, &mut owner_account], + &[Check::err(TokenError::MintMismatch.into())], ) ); @@ -2901,6 +3159,7 @@ fn test_mint_to() { &mut account2_account, &mut owner2_account, ], + &[Check::err(TokenError::OwnerMismatch.into())], ) ); @@ -2912,6 +3171,7 @@ fn test_mint_to() { do_process_instruction( mint_to(&program_id, &mint_key, &account_key, &owner_key, &[], 0).unwrap(), vec![&mut mint_account, &mut account_account, &mut owner_account], + &[Check::err(ProgramError::IncorrectProgramId)], ) ); mint_account.owner = program_id; @@ -2924,6 +3184,7 @@ fn test_mint_to() { do_process_instruction( mint_to(&program_id, &mint_key, &account_key, &owner_key, &[], 0).unwrap(), vec![&mut mint_account, &mut account_account, &mut owner_account], + &[Check::err(ProgramError::IncorrectProgramId)], ) ); account_account.owner = program_id; @@ -2946,6 +3207,7 @@ fn test_mint_to() { &mut uninitialized_account, &mut owner_account, ], + &[Check::err(ProgramError::UninitializedAccount)], ) ); @@ -2961,6 +3223,7 @@ fn test_mint_to() { ) .unwrap(), vec![&mut mint_account, &mut owner_account], + &[Check::success()], ) .unwrap(); assert_eq!( @@ -2968,6 +3231,7 @@ fn test_mint_to() { do_process_instruction( mint_to(&program_id, &mint_key, &account2_key, &owner_key, &[], 42).unwrap(), vec![&mut mint_account, &mut account2_account, &mut owner_account], + &[Check::err(TokenError::FixedSupply.into())], ) ); } @@ -2997,6 +3261,7 @@ fn test_burn_dups() { do_process_instruction_dups( initialize_mint(&program_id, &mint_key, &owner_key, None, 2).unwrap(), vec![mint_info.clone(), rent_info.clone()], + &[Check::success()], ) .unwrap(); @@ -3009,6 +3274,7 @@ fn test_burn_dups() { account1_info.clone(), rent_info.clone(), ], + &[Check::success()], ) .unwrap(); @@ -3016,6 +3282,7 @@ fn test_burn_dups() { do_process_instruction_dups( mint_to(&program_id, &mint_key, &account1_key, &owner_key, &[], 1000).unwrap(), vec![mint_info.clone(), account1_info.clone(), owner_info.clone()], + &[Check::success()], ) .unwrap(); @@ -3035,6 +3302,7 @@ fn test_burn_dups() { mint_info.clone(), account1_info.clone(), ], + &[Check::success()], ) .unwrap(); @@ -3055,6 +3323,7 @@ fn test_burn_dups() { mint_info.clone(), account1_info.clone(), ], + &[Check::success()], ) .unwrap(); @@ -3062,6 +3331,7 @@ fn test_burn_dups() { do_process_instruction_dups( mint_to(&program_id, &mint_key, &account1_key, &owner_key, &[], 1000).unwrap(), vec![mint_info.clone(), account1_info.clone(), owner_info.clone()], + &[Check::success()], ) .unwrap(); let mut account = Account::unpack_unchecked(&account1_info.data.borrow()).unwrap(); @@ -3070,6 +3340,7 @@ fn test_burn_dups() { do_process_instruction_dups( burn(&program_id, &account1_key, &mint_key, &mint_key, &[], 500).unwrap(), vec![account1_info.clone(), mint_info.clone(), mint_info.clone()], + &[Check::success()], ) .unwrap(); @@ -3086,6 +3357,7 @@ fn test_burn_dups() { ) .unwrap(), vec![account1_info.clone(), mint_info.clone(), mint_info.clone()], + &[Check::success()], ) .unwrap(); @@ -3093,6 +3365,7 @@ fn test_burn_dups() { do_process_instruction_dups( mint_to(&program_id, &mint_key, &account1_key, &owner_key, &[], 1000).unwrap(), vec![mint_info.clone(), account1_info.clone(), owner_info.clone()], + &[Check::success()], ) .unwrap(); let mut account = Account::unpack_unchecked(&account1_info.data.borrow()).unwrap(); @@ -3115,6 +3388,7 @@ fn test_burn_dups() { mint_info.clone(), account1_info.clone(), ], + &[Check::success()], ) .unwrap(); @@ -3135,6 +3409,7 @@ fn test_burn_dups() { mint_info.clone(), account1_info.clone(), ], + &[Check::success()], ) .unwrap(); @@ -3142,6 +3417,7 @@ fn test_burn_dups() { do_process_instruction_dups( mint_to(&program_id, &mint_key, &account1_key, &owner_key, &[], 1000).unwrap(), vec![mint_info.clone(), account1_info.clone(), owner_info.clone()], + &[Check::success()], ) .unwrap(); let mut account = Account::unpack_unchecked(&account1_info.data.borrow()).unwrap(); @@ -3152,6 +3428,7 @@ fn test_burn_dups() { do_process_instruction_dups( burn(&program_id, &account1_key, &mint_key, &mint_key, &[], 500).unwrap(), vec![account1_info.clone(), mint_info.clone(), mint_info.clone()], + &[Check::success()], ) .unwrap(); @@ -3168,6 +3445,7 @@ fn test_burn_dups() { ) .unwrap(), vec![account1_info.clone(), mint_info.clone(), mint_info.clone()], + &[Check::success()], ) .unwrap(); } @@ -3215,6 +3493,7 @@ fn test_burn() { do_process_instruction( initialize_mint(&program_id, &mint_key, &owner_key, None, 2).unwrap(), vec![&mut mint_account, &mut rent_sysvar], + &[Check::success()], ) .unwrap(); @@ -3227,6 +3506,7 @@ fn test_burn() { &mut owner_account, &mut rent_sysvar, ], + &[Check::success()], ) .unwrap(); @@ -3239,6 +3519,7 @@ fn test_burn() { &mut owner_account, &mut rent_sysvar, ], + &[Check::success()], ) .unwrap(); @@ -3251,6 +3532,7 @@ fn test_burn() { &mut owner_account, &mut rent_sysvar, ], + &[Check::success()], ) .unwrap(); @@ -3263,6 +3545,7 @@ fn test_burn() { &mut owner_account, &mut rent_sysvar, ], + &[Check::success()], ) .unwrap(); @@ -3270,6 +3553,7 @@ fn test_burn() { do_process_instruction( mint_to(&program_id, &mint_key, &account_key, &owner_key, &[], 1000).unwrap(), vec![&mut mint_account, &mut account_account, &mut owner_account], + &[Check::success()], ) .unwrap(); @@ -3277,6 +3561,7 @@ fn test_burn() { do_process_instruction( mint_to(&program_id, &mint_key, &mismatch_key, &owner_key, &[], 1000).unwrap(), vec![&mut mint_account, &mut mismatch_account, &mut owner_account], + &[Check::success()], ) .unwrap(); let mut account = Account::unpack_unchecked(&mismatch_account.data).unwrap(); @@ -3296,6 +3581,7 @@ fn test_burn() { &mut mint_account, &mut delegate_account ], + &[Check::err(TokenError::OwnerMismatch.into())], ) ); @@ -3305,6 +3591,7 @@ fn test_burn() { do_process_instruction( burn(&program_id, &account_key, &mint_key, &owner2_key, &[], 42).unwrap(), vec![&mut account_account, &mut mint_account, &mut owner2_account], + &[Check::err(TokenError::OwnerMismatch.into())], ) ); @@ -3316,6 +3603,7 @@ fn test_burn() { do_process_instruction( burn(&program_id, &account_key, &mint_key, &owner_key, &[], 0).unwrap(), vec![&mut account_account, &mut mint_account, &mut owner_account], + &[Check::err(ProgramError::IncorrectProgramId)], ) ); account_account.owner = program_id; @@ -3328,6 +3616,7 @@ fn test_burn() { do_process_instruction( burn(&program_id, &account_key, &mint_key, &owner_key, &[], 0).unwrap(), vec![&mut account_account, &mut mint_account, &mut owner_account], + &[Check::err(ProgramError::IncorrectProgramId)], ) ); mint_account.owner = program_id; @@ -3338,6 +3627,7 @@ fn test_burn() { do_process_instruction( burn(&program_id, &mismatch_key, &mint_key, &owner_key, &[], 42).unwrap(), vec![&mut mismatch_account, &mut mint_account, &mut owner_account], + &[Check::err(TokenError::MintMismatch.into())], ) ); @@ -3345,6 +3635,7 @@ fn test_burn() { do_process_instruction( burn(&program_id, &account_key, &mint_key, &owner_key, &[], 21).unwrap(), vec![&mut account_account, &mut mint_account, &mut owner_account], + &[Check::success()], ) .unwrap(); @@ -3354,6 +3645,7 @@ fn test_burn() { do_process_instruction( burn_checked(&program_id, &account_key, &mint_key, &owner_key, &[], 21, 3).unwrap(), vec![&mut account_account, &mut mint_account, &mut owner_account], + &[Check::err(TokenError::MintDecimalsMismatch.into())], ) ); @@ -3361,6 +3653,15 @@ fn test_burn() { do_process_instruction( burn_checked(&program_id, &account_key, &mint_key, &owner_key, &[], 21, 2).unwrap(), vec![&mut account_account, &mut mint_account, &mut owner_account], + &[ + Check::success(), + Check::account(&mint_key) + .data_slice(36, &(2000u64 - 42).to_le_bytes()) + .build(), + Check::account(&account_key) + .data_slice(64, &(1000u64 - 42).to_le_bytes()) + .build(), + ], ) .unwrap(); @@ -3383,6 +3684,7 @@ fn test_burn() { ) .unwrap(), vec![&mut account_account, &mut mint_account, &mut owner_account], + &[Check::err(TokenError::InsufficientFunds.into())], ) ); @@ -3402,6 +3704,7 @@ fn test_burn() { &mut delegate_account, &mut owner_account, ], + &[Check::success()], ) .unwrap(); @@ -3419,6 +3722,7 @@ fn test_burn() { ) .unwrap(), vec![&mut account_account, &mut mint_account, &mut owner2_account], + &[Check::err(TokenError::OwnerMismatch.into())], ) ); @@ -3432,6 +3736,7 @@ fn test_burn() { &mut mint_account, &mut delegate_account ], + &[Check::err(TokenError::InsufficientFunds.into())], ) ); @@ -3443,6 +3748,15 @@ fn test_burn() { &mut mint_account, &mut delegate_account, ], + &[ + Check::success(), + Check::account(&mint_key) + .data_slice(36, &(2000u64 - 42 - 84).to_le_bytes()) + .build(), + Check::account(&account_key) + .data_slice(64, &(1000u64 - 42 - 84).to_le_bytes()) + .build(), + ], ) .unwrap(); @@ -3462,6 +3776,7 @@ fn test_burn() { &mut mint_account, &mut delegate_account ], + &[Check::err(TokenError::OwnerMismatch.into())], ) ); } @@ -3500,6 +3815,7 @@ fn test_burn_and_close_system_and_incinerator_tokens() { do_process_instruction( initialize_mint2(&program_id, &mint_key, &owner_key, None, 2).unwrap(), vec![&mut mint_account], + &[Check::success()], ) .unwrap(); @@ -3507,6 +3823,7 @@ fn test_burn_and_close_system_and_incinerator_tokens() { do_process_instruction( initialize_account3(&program_id, &account_key, &mint_key, &owner_key).unwrap(), vec![&mut account_account, &mut mint_account], + &[Check::success()], ) .unwrap(); @@ -3520,6 +3837,7 @@ fn test_burn_and_close_system_and_incinerator_tokens() { ) .unwrap(), vec![&mut incinerator_account, &mut mint_account], + &[Check::success()], ) .unwrap(); do_process_instruction( @@ -3531,6 +3849,7 @@ fn test_burn_and_close_system_and_incinerator_tokens() { ) .unwrap(), vec![&mut system_account, &mut mint_account], + &[Check::success()], ) .unwrap(); @@ -3538,6 +3857,7 @@ fn test_burn_and_close_system_and_incinerator_tokens() { do_process_instruction( mint_to(&program_id, &mint_key, &account_key, &owner_key, &[], 1000).unwrap(), vec![&mut mint_account, &mut account_account, &mut owner_account], + &[Check::success()], ) .unwrap(); @@ -3557,6 +3877,7 @@ fn test_burn_and_close_system_and_incinerator_tokens() { &mut incinerator_account, &mut owner_account, ], + &[Check::success()], ) .unwrap(); do_process_instruction( @@ -3574,6 +3895,7 @@ fn test_burn_and_close_system_and_incinerator_tokens() { &mut system_account, &mut owner_account, ], + &[Check::success()], ) .unwrap(); @@ -3594,6 +3916,7 @@ fn test_burn_and_close_system_and_incinerator_tokens() { &mut mock_incinerator_account, &mut owner_account, ], + &[Check::err(TokenError::NonNativeHasBalance.into())], ) ); assert_eq!( @@ -3612,6 +3935,7 @@ fn test_burn_and_close_system_and_incinerator_tokens() { &mut mock_incinerator_account, &mut owner_account, ], + &[Check::err(TokenError::NonNativeHasBalance.into())], ) ); @@ -3631,6 +3955,7 @@ fn test_burn_and_close_system_and_incinerator_tokens() { &mut mint_account, &mut recipient_account, ], + &[Check::success()], ) .unwrap(); do_process_instruction( @@ -3648,6 +3973,7 @@ fn test_burn_and_close_system_and_incinerator_tokens() { &mut mint_account, &mut recipient_account, ], + &[Check::success()], ) .unwrap(); @@ -3668,6 +3994,7 @@ fn test_burn_and_close_system_and_incinerator_tokens() { &mut recipient_account, &mut owner_account, ], + &[Check::err(ProgramError::InvalidAccountData)], ) ); assert_eq!( @@ -3686,6 +4013,7 @@ fn test_burn_and_close_system_and_incinerator_tokens() { &mut recipient_account, &mut owner_account, ], + &[Check::err(ProgramError::InvalidAccountData)], ) ); @@ -3704,6 +4032,7 @@ fn test_burn_and_close_system_and_incinerator_tokens() { &mut mock_incinerator_account, &mut owner_account, ], + &[Check::success()], ) .unwrap(); @@ -3721,6 +4050,7 @@ fn test_burn_and_close_system_and_incinerator_tokens() { &mut mock_incinerator_account, &mut owner_account, ], + &[Check::success()], ) .unwrap(); } @@ -3769,6 +4099,7 @@ fn test_multisig() { &mut rent_sysvar, account_info_iter.next().unwrap(), ], + &[Check::err(TokenError::NotRentExempt.into())], ) ); @@ -3784,6 +4115,7 @@ fn test_multisig() { &mut rent_sysvar, account_info_iter.next().unwrap(), ], + &[Check::success()], ) .unwrap(); @@ -3792,6 +4124,7 @@ fn test_multisig() { do_process_instruction( initialize_multisig2(&program_id, &multisig_key, &[&signer_keys[0]], 1).unwrap(), vec![&mut multisig_account2, account_info_iter.next().unwrap()], + &[Check::success()], ) .unwrap(); @@ -3820,6 +4153,7 @@ fn test_multisig() { account_info_iter.next().unwrap(), account_info_iter.next().unwrap(), ], + &[Check::success()], ) .unwrap(); @@ -3827,6 +4161,7 @@ fn test_multisig() { do_process_instruction( initialize_mint(&program_id, &mint_key, &multisig_key, None, 2).unwrap(), vec![&mut mint_account, &mut rent_sysvar], + &[Check::success()], ) .unwrap(); @@ -3839,6 +4174,7 @@ fn test_multisig() { &mut multisig_account, &mut rent_sysvar, ], + &[Check::success()], ) .unwrap(); @@ -3857,6 +4193,7 @@ fn test_multisig() { &mut multisig_account, &mut rent_sysvar, ], + &[Check::success()], ) .unwrap(); @@ -3878,6 +4215,7 @@ fn test_multisig() { &mut multisig_account, account_info_iter.next().unwrap(), ], + &[Check::success()], ) .unwrap(); @@ -3899,6 +4237,7 @@ fn test_multisig() { &mut multisig_account, account_info_iter.next().unwrap(), ], + &[Check::success()], ) .unwrap(); @@ -3920,6 +4259,7 @@ fn test_multisig() { &mut multisig_account, account_info_iter.next().unwrap(), ], + &[Check::success()], ) .unwrap(); @@ -3951,6 +4291,7 @@ fn test_multisig() { account_info_iter.next().unwrap(), account_info_iter.next().unwrap(), ], + &[Check::success()], ) .unwrap(); @@ -3972,6 +4313,7 @@ fn test_multisig() { &mut multisig_account, account_info_iter.next().unwrap(), ], + &[Check::success()], ) .unwrap(); @@ -3993,6 +4335,7 @@ fn test_multisig() { &mut multisig_account, account_info_iter.next().unwrap(), ], + &[Check::success()], ) .unwrap(); @@ -4024,6 +4367,7 @@ fn test_multisig() { account_info_iter.next().unwrap(), account_info_iter.next().unwrap(), ], + &[Check::success()], ) .unwrap(); @@ -4047,6 +4391,7 @@ fn test_multisig() { ) .unwrap(), vec![&mut mint2_account, &mut rent_sysvar], + &[Check::success()], ) .unwrap(); do_process_instruction( @@ -4057,6 +4402,7 @@ fn test_multisig() { &mut owner_account, &mut rent_sysvar, ], + &[Check::success()], ) .unwrap(); let account_info_iter = &mut signer_accounts.iter_mut(); @@ -4076,6 +4422,7 @@ fn test_multisig() { &mut multisig_account, account_info_iter.next().unwrap(), ], + &[Check::success()], ) .unwrap(); let account_info_iter = &mut signer_accounts.iter_mut(); @@ -4094,6 +4441,7 @@ fn test_multisig() { &mut multisig_account, account_info_iter.next().unwrap(), ], + &[Check::success()], ) .unwrap(); @@ -4114,6 +4462,7 @@ fn test_multisig() { &mut multisig_account, account_info_iter.next().unwrap(), ], + &[Check::success()], ) .unwrap(); @@ -4134,6 +4483,7 @@ fn test_multisig() { &mut multisig_account, account_info_iter.next().unwrap(), ], + &[Check::success()], ) .unwrap(); } @@ -4154,6 +4504,7 @@ fn test_owner_close_account_dups() { do_process_instruction_dups( initialize_mint(&program_id, &mint_key, &owner_key, None, 2).unwrap(), vec![mint_info.clone(), rent_info.clone()], + &[Check::success()], ) .unwrap(); @@ -4181,6 +4532,7 @@ fn test_owner_close_account_dups() { to_close_account_info.clone(), rent_info.clone(), ], + &[Check::success()], ) .unwrap(); @@ -4199,6 +4551,10 @@ fn test_owner_close_account_dups() { destination_account_info.clone(), to_close_account_info.clone(), ], + &[ + Check::success(), + Check::account(&to_close_key).data(&[]).build(), + ], ) .unwrap(); assert_eq!(*to_close_account_info.data.borrow(), &[0u8; Account::LEN]); @@ -4220,6 +4576,7 @@ fn test_close_authority_close_account_dups() { do_process_instruction_dups( initialize_mint(&program_id, &mint_key, &owner_key, None, 2).unwrap(), vec![mint_info.clone(), rent_info.clone()], + &[Check::success()], ) .unwrap(); @@ -4247,6 +4604,7 @@ fn test_close_authority_close_account_dups() { to_close_account_info.clone(), rent_info.clone(), ], + &[Check::success()], ) .unwrap(); let mut account = Account::unpack_unchecked(&to_close_account_info.data.borrow()).unwrap(); @@ -4267,6 +4625,10 @@ fn test_close_authority_close_account_dups() { destination_account_info.clone(), to_close_account_info.clone(), ], + &[ + Check::success(), + Check::account(&to_close_key).data(&[]).build(), + ], ) .unwrap(); assert_eq!(*to_close_account_info.data.borrow(), &[0u8; Account::LEN]); @@ -4312,6 +4674,7 @@ fn test_close_account() { &mut account3_account, &mut owner2_account, ], + &[Check::err(ProgramError::UninitializedAccount)], ) ); @@ -4319,6 +4682,7 @@ fn test_close_account() { do_process_instruction( initialize_mint(&program_id, &mint_key, &owner_key, None, 2).unwrap(), vec![&mut mint_account, &mut rent_sysvar], + &[Check::success()], ) .unwrap(); do_process_instruction( @@ -4329,6 +4693,7 @@ fn test_close_account() { &mut owner_account, &mut rent_sysvar, ], + &[Check::success()], ) .unwrap(); do_process_instruction( @@ -4339,6 +4704,12 @@ fn test_close_account() { &mut owner_account, &mut rent_sysvar, ], + &[ + Check::success(), + Check::account(&account_key) + .data_slice(64, &42u64.to_le_bytes()) + .build(), + ], ) .unwrap(); let account = Account::unpack_unchecked(&account_account.data).unwrap(); @@ -4359,6 +4730,15 @@ fn test_close_account() { &mut owner_account, &mut rent_sysvar, ], + &[ + Check::success(), + Check::account(&account2_key) + .data_slice(109, &[1, 0, 0, 0]) + .build(), + Check::account(&account2_key) + .data_slice(64, &42u64.to_le_bytes()) + .build(), + ], ) .unwrap(); let account = Account::unpack_unchecked(&account2_account.data).unwrap(); @@ -4375,6 +4755,12 @@ fn test_close_account() { &mut account3_account, &mut owner_account, ], + &[ + Check::err(TokenError::NonNativeHasBalance.into()), + Check::account(&account_key) + .lamports(account_minimum_balance()) + .build() + ], ) ); assert_eq!(account_account.lamports, account_minimum_balance()); @@ -4383,6 +4769,7 @@ fn test_close_account() { do_process_instruction( burn(&program_id, &account_key, &mint_key, &owner_key, &[], 42).unwrap(), vec![&mut account_account, &mut mint_account, &mut owner_account], + &[Check::success()], ) .unwrap(); @@ -4396,6 +4783,7 @@ fn test_close_account() { &mut account3_account, &mut owner2_account, ], + &[Check::err(TokenError::OwnerMismatch.into())], ) ); @@ -4407,6 +4795,14 @@ fn test_close_account() { &mut account3_account, &mut owner_account, ], + &[ + Check::success(), + Check::account(&account_key).data(&[]).build(), + Check::account(&account_key).lamports(0).build(), + Check::account(&account3_key) + .lamports(2 * account_minimum_balance()) + .build(), + ], ) .unwrap(); assert!(account_account.data.is_empty()); @@ -4434,6 +4830,7 @@ fn test_close_account() { &mut owner_account, &mut rent_sysvar, ], + &[Check::success()], ) .unwrap(); account_account.lamports = 2; @@ -4449,6 +4846,7 @@ fn test_close_account() { ) .unwrap(), vec![&mut account_account, &mut owner_account], + &[Check::success()], ) .unwrap(); @@ -4462,6 +4860,7 @@ fn test_close_account() { &mut account3_account, &mut owner_account, ], + &[Check::err(TokenError::OwnerMismatch.into())], ) ); @@ -4473,6 +4872,14 @@ fn test_close_account() { &mut account3_account, &mut owner2_account, ], + &[ + Check::success(), + Check::account(&account_key).data(&[]).build(), + Check::account(&account_key).lamports(0).build(), + Check::account(&account3_key) + .lamports(2 * account_minimum_balance() + 2) + .build(), + ], ) .unwrap(); assert!(account_account.data.is_empty()); @@ -4487,6 +4894,13 @@ fn test_close_account() { &mut account3_account, &mut owner_account, ], + &[ + Check::success(), + Check::account(&account2_key).data(&[]).build(), + Check::account(&account3_key) + .lamports(3 * account_minimum_balance() + 2 + 42) + .build(), + ], ) .unwrap(); assert!(account2_account.data.is_empty()); @@ -4537,6 +4951,15 @@ fn test_native_token() { &mut owner_account, &mut rent_sysvar, ], + &[ + Check::success(), + Check::account(&account_key) + .data_slice(109, &[1, 0, 0, 0]) + .build(), + Check::account(&account_key) + .data_slice(64, &40u64.to_le_bytes()) + .build(), + ], ) .unwrap(); let account = Account::unpack_unchecked(&account_account.data).unwrap(); @@ -4558,6 +4981,15 @@ fn test_native_token() { &mut owner_account, &mut rent_sysvar, ], + &[ + Check::success(), + Check::account(&account2_key) + .data_slice(109, &[1, 0, 0, 0]) + .build(), + Check::account(&account2_key) + .data_slice(64, &0u64.to_le_bytes()) + .build(), + ], ) .unwrap(); let account = Account::unpack_unchecked(&account2_account.data).unwrap(); @@ -4578,6 +5010,7 @@ fn test_native_token() { ) .unwrap(), vec![&mut mint_account, &mut account_account, &mut owner_account], + &[Check::err(TokenError::NativeNotSupported.into())], ) ); @@ -4588,6 +5021,7 @@ fn test_native_token() { do_process_instruction( initialize_mint(&program_id, &bogus_mint_key, &owner_key, None, 2).unwrap(), vec![&mut bogus_mint_account, &mut rent_sysvar], + &[Check::success()], ) .unwrap(); @@ -4608,6 +5042,7 @@ fn test_native_token() { &mut bogus_mint_account, &mut owner_account ], + &[Check::err(TokenError::NativeNotSupported.into())], ) ); @@ -4629,6 +5064,7 @@ fn test_native_token() { &mut account2_account, &mut owner_account, ], + &[Check::err(TokenError::InsufficientFunds.into())], ) ); @@ -4648,6 +5084,27 @@ fn test_native_token() { &mut account2_account, &mut owner_account, ], + &[ + Check::success(), + Check::account(&account_key) + .lamports(account_minimum_balance()) + .build(), + Check::account(&account_key) + .data_slice(109, &[1, 0, 0, 0]) + .build(), + Check::account(&account_key) + .data_slice(64, &0u64.to_le_bytes()) + .build(), + Check::account(&account2_key) + .lamports(account_minimum_balance() + 40) + .build(), + Check::account(&account_key) + .data_slice(109, &[1, 0, 0, 0]) + .build(), + Check::account(&account2_key) + .data_slice(64, &40u64.to_le_bytes()) + .build(), + ], ) .unwrap(); assert_eq!(account_account.lamports, account_minimum_balance()); @@ -4671,6 +5128,15 @@ fn test_native_token() { ) .unwrap(), vec![&mut account_account, &mut owner_account], + &[ + Check::success(), + Check::account(&account_key) + .data_slice(129, &[1, 0, 0, 0]) + .build(), + Check::account(&account_key) + .data_slice(133, owner3_key.as_ref()) + .build(), + ], ) .unwrap(); let account = Account::unpack_unchecked(&account_account.data).unwrap(); @@ -4688,6 +5154,12 @@ fn test_native_token() { ) .unwrap(), vec![&mut account_account, &mut owner_account], + &[ + Check::success(), + Check::account(&account_key) + .data_slice(129, &[0, 0, 0, 0]) + .build(), + ], ) .unwrap(); @@ -4703,6 +5175,14 @@ fn test_native_token() { &mut account3_account, &mut owner2_account, ], + &[ + Check::success(), + Check::account(&account_key).lamports(0).build(), + Check::account(&account3_key) + .lamports(2 * account_minimum_balance()) + .build(), + Check::account(&account_key).data(&[]).build(), + ], ) .unwrap(); assert_eq!(account_account.lamports, 0); @@ -4740,6 +5220,7 @@ fn test_overflow() { do_process_instruction( initialize_mint(&program_id, &mint_key, &mint_owner_key, None, 2).unwrap(), vec![&mut mint_account, &mut rent_sysvar], + &[Check::success()], ) .unwrap(); @@ -4752,6 +5233,7 @@ fn test_overflow() { &mut owner_account, &mut rent_sysvar, ], + &[Check::success()], ) .unwrap(); @@ -4764,6 +5246,7 @@ fn test_overflow() { &mut owner2_account, &mut rent_sysvar, ], + &[Check::success()], ) .unwrap(); @@ -4783,6 +5266,12 @@ fn test_overflow() { &mut account_account, &mut mint_owner_account, ], + &[ + Check::success(), + Check::account(&account_key) + .data_slice(64, &u64::MAX.to_le_bytes()) + .build(), + ], ) .unwrap(); let account = Account::unpack_unchecked(&account_account.data).unwrap(); @@ -4806,6 +5295,12 @@ fn test_overflow() { &mut account_account, &mut mint_owner_account, ], + &[ + Check::err(TokenError::Overflow.into()), + Check::account(&account_key) + .data_slice(64, &u64::MAX.to_le_bytes()) + .build(), + ], ) ); let account = Account::unpack_unchecked(&account_account.data).unwrap(); @@ -4829,6 +5324,7 @@ fn test_overflow() { &mut account2_account, &mut mint_owner_account, ], + &[Check::err(TokenError::Overflow.into())], ) ); @@ -4836,6 +5332,12 @@ fn test_overflow() { do_process_instruction( burn(&program_id, &account_key, &mint_key, &owner_key, &[], 100).unwrap(), vec![&mut account_account, &mut mint_account, &mut owner_account], + &[ + Check::success(), + Check::account(&account_key) + .data_slice(64, &(u64::MAX - 100).to_le_bytes()) + .build(), + ], ) .unwrap(); let account = Account::unpack_unchecked(&account_account.data).unwrap(); @@ -4856,6 +5358,12 @@ fn test_overflow() { &mut account_account, &mut mint_owner_account, ], + &[ + Check::success(), + Check::account(&account_key) + .data_slice(64, &u64::MAX.to_le_bytes()) + .build(), + ], ) .unwrap(); let account = Account::unpack_unchecked(&account_account.data).unwrap(); @@ -4883,6 +5391,7 @@ fn test_overflow() { &mut account_account, &mut owner2_account, ], + &[Check::err(TokenError::Overflow.into())], ) ); } @@ -4913,6 +5422,7 @@ fn test_frozen() { do_process_instruction( initialize_mint(&program_id, &mint_key, &owner_key, None, 2).unwrap(), vec![&mut mint_account, &mut rent_sysvar], + &[Check::success()], ) .unwrap(); @@ -4925,6 +5435,7 @@ fn test_frozen() { &mut owner_account, &mut rent_sysvar, ], + &[Check::success()], ) .unwrap(); @@ -4937,6 +5448,7 @@ fn test_frozen() { &mut owner_account, &mut rent_sysvar, ], + &[Check::success()], ) .unwrap(); @@ -4944,6 +5456,7 @@ fn test_frozen() { do_process_instruction( mint_to(&program_id, &mint_key, &account_key, &owner_key, &[], 1000).unwrap(), vec![&mut mint_account, &mut account_account, &mut owner_account], + &[Check::success()], ) .unwrap(); @@ -4968,6 +5481,7 @@ fn test_frozen() { &mut account2_account, &mut owner_account, ], + &[Check::err(TokenError::AccountFrozen.into())], ) ); @@ -4994,6 +5508,7 @@ fn test_frozen() { &mut account2_account, &mut owner_account, ], + &[Check::err(TokenError::AccountFrozen.into())], ) ); @@ -5020,6 +5535,7 @@ fn test_frozen() { &mut delegate_account, &mut owner_account, ], + &[Check::err(TokenError::AccountFrozen.into())], ) ); @@ -5033,6 +5549,7 @@ fn test_frozen() { do_process_instruction( revoke(&program_id, &account_key, &owner_key, &[]).unwrap(), vec![&mut account_account, &mut owner_account], + &[Check::err(TokenError::AccountFrozen.into())], ) ); @@ -5051,6 +5568,7 @@ fn test_frozen() { ) .unwrap(), vec![&mut account_account, &mut owner_account,], + &[Check::err(TokenError::AccountFrozen.into())], ) ); @@ -5060,6 +5578,7 @@ fn test_frozen() { do_process_instruction( mint_to(&program_id, &mint_key, &account_key, &owner_key, &[], 100).unwrap(), vec![&mut mint_account, &mut account_account, &mut owner_account,], + &[Check::err(TokenError::AccountFrozen.into())], ) ); @@ -5069,6 +5588,7 @@ fn test_frozen() { do_process_instruction( burn(&program_id, &account_key, &mint_key, &owner_key, &[], 100).unwrap(), vec![&mut account_account, &mut mint_account, &mut owner_account], + &[Check::err(TokenError::AccountFrozen.into())], ) ); } @@ -5096,6 +5616,7 @@ fn test_freeze_thaw_dups() { do_process_instruction_dups( initialize_mint(&program_id, &mint_key, &owner_key, Some(&account1_key), 2).unwrap(), vec![mint_info.clone(), rent_info.clone()], + &[Check::success()], ) .unwrap(); @@ -5108,6 +5629,7 @@ fn test_freeze_thaw_dups() { account1_info.clone(), rent_info.clone(), ], + &[Check::success()], ) .unwrap(); @@ -5119,6 +5641,7 @@ fn test_freeze_thaw_dups() { mint_info.clone(), account1_info.clone(), ], + &[Check::success()], ) .unwrap(); @@ -5133,6 +5656,7 @@ fn test_freeze_thaw_dups() { mint_info.clone(), account1_info.clone(), ], + &[Check::success()], ) .unwrap(); } @@ -5161,6 +5685,7 @@ fn test_freeze_account() { do_process_instruction( initialize_mint(&program_id, &mint_key, &owner_key, None, 2).unwrap(), vec![&mut mint_account, &mut rent_sysvar], + &[Check::success()], ) .unwrap(); @@ -5173,6 +5698,7 @@ fn test_freeze_account() { &mut account_owner_account, &mut rent_sysvar, ], + &[Check::success()], ) .unwrap(); @@ -5180,6 +5706,7 @@ fn test_freeze_account() { do_process_instruction( mint_to(&program_id, &mint_key, &account_key, &owner_key, &[], 1000).unwrap(), vec![&mut mint_account, &mut account_account, &mut owner_account], + &[Check::success()], ) .unwrap(); @@ -5189,6 +5716,7 @@ fn test_freeze_account() { do_process_instruction( freeze_account(&program_id, &account_key, &mint_key, &owner_key, &[]).unwrap(), vec![&mut account_account, &mut mint_account, &mut owner_account], + &[Check::err(TokenError::MintCannotFreeze.into())], ) ); @@ -5201,6 +5729,7 @@ fn test_freeze_account() { do_process_instruction( freeze_account(&program_id, &account_key, &mint_key, &owner2_key, &[]).unwrap(), vec![&mut account_account, &mut mint_account, &mut owner2_account], + &[Check::err(TokenError::OwnerMismatch.into())], ) ); @@ -5210,6 +5739,7 @@ fn test_freeze_account() { do_process_instruction( thaw_account(&program_id, &account_key, &mint_key, &owner2_key, &[]).unwrap(), vec![&mut account_account, &mut mint_account, &mut owner2_account], + &[Check::err(TokenError::InvalidState.into())], ) ); @@ -5217,6 +5747,12 @@ fn test_freeze_account() { do_process_instruction( freeze_account(&program_id, &account_key, &mint_key, &owner_key, &[]).unwrap(), vec![&mut account_account, &mut mint_account, &mut owner_account], + &[ + Check::success(), + Check::account(&account_key) + .data_slice(108, &[AccountState::Frozen as u8]) + .build(), + ], ) .unwrap(); let account = Account::unpack_unchecked(&account_account.data).unwrap(); @@ -5228,6 +5764,7 @@ fn test_freeze_account() { do_process_instruction( freeze_account(&program_id, &account_key, &mint_key, &owner_key, &[]).unwrap(), vec![&mut account_account, &mut mint_account, &mut owner_account], + &[Check::err(TokenError::InvalidState.into())], ) ); @@ -5237,6 +5774,7 @@ fn test_freeze_account() { do_process_instruction( thaw_account(&program_id, &account_key, &mint_key, &owner2_key, &[]).unwrap(), vec![&mut account_account, &mut mint_account, &mut owner2_account], + &[Check::err(TokenError::OwnerMismatch.into())], ) ); @@ -5244,6 +5782,12 @@ fn test_freeze_account() { do_process_instruction( thaw_account(&program_id, &account_key, &mint_key, &owner_key, &[]).unwrap(), vec![&mut account_account, &mut mint_account, &mut owner_account], + &[ + Check::success(), + Check::account(&account_key) + .data_slice(108, &[AccountState::Initialized as u8]) + .build(), + ], ) .unwrap(); let account = Account::unpack_unchecked(&account_account.data).unwrap(); @@ -5280,6 +5824,7 @@ fn test_initialize_account2_and_3() { do_process_instruction( initialize_mint(&program_id, &mint_key, &owner_key, None, 2).unwrap(), vec![&mut mint_account, &mut rent_sysvar], + &[Check::success()], ) .unwrap(); @@ -5291,12 +5836,14 @@ fn test_initialize_account2_and_3() { &mut owner_account, &mut rent_sysvar, ], + &[Check::success()], ) .unwrap(); do_process_instruction( initialize_account2(&program_id, &account_key, &mint_key, &owner_key).unwrap(), vec![&mut account2_account, &mut mint_account, &mut rent_sysvar], + &[Check::success()], ) .unwrap(); @@ -5305,6 +5852,7 @@ fn test_initialize_account2_and_3() { do_process_instruction( initialize_account3(&program_id, &account_key, &mint_key, &owner_key).unwrap(), vec![&mut account3_account, &mut mint_account], + &[Check::success()], ) .unwrap(); @@ -5339,6 +5887,7 @@ fn test_sync_native() { do_process_instruction( initialize_mint(&program_id, &mint_key, &owner_key, None, 2).unwrap(), vec![&mut mint_account, &mut rent_sysvar], + &[Check::success()], ) .unwrap(); @@ -5351,6 +5900,15 @@ fn test_sync_native() { &mut owner_account, &mut rent_sysvar, ], + &[ + Check::success(), + Check::account(&non_native_account_key) + .data_slice(109, &[0, 0, 0, 0]) + .build(), + Check::account(&non_native_account_key) + .data_slice(64, &0u64.to_le_bytes()) + .build(), + ], ) .unwrap(); @@ -5364,6 +5922,7 @@ fn test_sync_native() { do_process_instruction( sync_native(&program_id, &non_native_account_key,).unwrap(), vec![&mut non_native_account], + &[Check::err(TokenError::NonNativeNotSupported.into())], ) ); @@ -5373,6 +5932,7 @@ fn test_sync_native() { do_process_instruction( sync_native(&program_id, &native_account_key,).unwrap(), vec![&mut native_account], + &[Check::err(ProgramError::UninitializedAccount)], ) ); @@ -5391,6 +5951,7 @@ fn test_sync_native() { &mut owner_account, &mut rent_sysvar, ], + &[Check::success()], ) .unwrap(); @@ -5402,6 +5963,15 @@ fn test_sync_native() { do_process_instruction( sync_native(&program_id, &native_account_key,).unwrap(), vec![&mut native_account], + &[ + Check::err(ProgramError::IncorrectProgramId), + Check::account(&native_account_key) + .data_slice(109, &[1, 0, 0, 0]) + .build(), + Check::account(&native_account_key) + .data_slice(64, &lamports.to_le_bytes()) + .build() + ], ) ); native_account.owner = program_id; @@ -5414,6 +5984,12 @@ fn test_sync_native() { do_process_instruction( sync_native(&program_id, &native_account_key).unwrap(), vec![&mut native_account], + &[ + Check::success(), + Check::account(&native_account_key) + .data_slice(64, &lamports.to_le_bytes()) + .build(), + ], ) .unwrap(); let account = Account::unpack_unchecked(&native_account.data).unwrap(); @@ -5427,6 +6003,12 @@ fn test_sync_native() { do_process_instruction( sync_native(&program_id, &native_account_key).unwrap(), vec![&mut native_account], + &[ + Check::success(), + Check::account(&native_account_key) + .data_slice(64, &new_lamports.to_le_bytes()) + .build(), + ], ) .unwrap(); let account = Account::unpack_unchecked(&native_account.data).unwrap(); @@ -5441,6 +6023,7 @@ fn test_sync_native() { do_process_instruction( sync_native(&program_id, &native_account_key,).unwrap(), vec![&mut native_account], + &[Check::err(TokenError::InvalidState.into())], ) ); } @@ -5461,19 +6044,24 @@ fn test_get_account_data_size() { do_process_instruction( get_account_data_size(&program_id, &mint_key).unwrap(), vec![&mut mint_account], + &[Check::err(TokenError::InvalidMint.into())], ) ); do_process_instruction( initialize_mint(&program_id, &mint_key, &owner_key, None, 2).unwrap(), vec![&mut mint_account, &mut rent_sysvar], + &[Check::success()], ) .unwrap(); - set_expected_data(Account::LEN.to_le_bytes().to_vec()); do_process_instruction( get_account_data_size(&program_id, &mint_key).unwrap(), vec![&mut mint_account], + &[ + Check::success(), + Check::return_data(&Account::LEN.to_le_bytes()), + ], ) .unwrap(); } @@ -5498,6 +6086,7 @@ fn test_initialize_immutable_owner() { do_process_instruction( initialize_mint(&program_id, &mint_key, &owner_key, None, 2).unwrap(), vec![&mut mint_account, &mut rent_sysvar], + &[Check::success()], ) .unwrap(); @@ -5505,6 +6094,7 @@ fn test_initialize_immutable_owner() { do_process_instruction( initialize_immutable_owner(&program_id, &account_key).unwrap(), vec![&mut account_account], + &[Check::success()], ) .unwrap(); @@ -5517,6 +6107,7 @@ fn test_initialize_immutable_owner() { &mut owner_account, &mut rent_sysvar, ], + &[Check::success()], ) .unwrap(); @@ -5526,6 +6117,7 @@ fn test_initialize_immutable_owner() { do_process_instruction( initialize_immutable_owner(&program_id, &account_key).unwrap(), vec![&mut account_account], + &[Check::err(TokenError::AlreadyInUse.into())], ) ); } @@ -5546,6 +6138,7 @@ fn test_amount_to_ui_amount() { do_process_instruction( amount_to_ui_amount(&program_id, &mint_key, 110).unwrap(), vec![&mut mint_account], + &[Check::err(TokenError::InvalidMint.into())], ) ); @@ -5553,34 +6146,35 @@ fn test_amount_to_ui_amount() { do_process_instruction( initialize_mint(&program_id, &mint_key, &owner_key, None, 2).unwrap(), vec![&mut mint_account, &mut rent_sysvar], + &[Check::success()], ) .unwrap(); - set_expected_data("0.23".as_bytes().to_vec()); do_process_instruction( amount_to_ui_amount(&program_id, &mint_key, 23).unwrap(), vec![&mut mint_account], + &[Check::success(), Check::return_data("0.23".as_bytes())], ) .unwrap(); - set_expected_data("1.1".as_bytes().to_vec()); do_process_instruction( amount_to_ui_amount(&program_id, &mint_key, 110).unwrap(), vec![&mut mint_account], + &[Check::success(), Check::return_data("1.1".as_bytes())], ) .unwrap(); - set_expected_data("42".as_bytes().to_vec()); do_process_instruction( amount_to_ui_amount(&program_id, &mint_key, 4200).unwrap(), vec![&mut mint_account], + &[Check::success(), Check::return_data("42".as_bytes())], ) .unwrap(); - set_expected_data("0".as_bytes().to_vec()); do_process_instruction( amount_to_ui_amount(&program_id, &mint_key, 0).unwrap(), vec![&mut mint_account], + &[Check::success(), Check::return_data("0".as_bytes())], ) .unwrap(); } @@ -5601,6 +6195,7 @@ fn test_ui_amount_to_amount() { do_process_instruction( ui_amount_to_amount(&program_id, &mint_key, "1.1").unwrap(), vec![&mut mint_account], + &[Check::err(TokenError::InvalidMint.into())], ) ); @@ -5608,69 +6203,70 @@ fn test_ui_amount_to_amount() { do_process_instruction( initialize_mint(&program_id, &mint_key, &owner_key, None, 2).unwrap(), vec![&mut mint_account, &mut rent_sysvar], + &[Check::success()], ) .unwrap(); - set_expected_data(23u64.to_le_bytes().to_vec()); do_process_instruction( ui_amount_to_amount(&program_id, &mint_key, "0.23").unwrap(), vec![&mut mint_account], + &[Check::success(), Check::return_data(&23u64.to_le_bytes())], ) .unwrap(); - set_expected_data(20u64.to_le_bytes().to_vec()); do_process_instruction( ui_amount_to_amount(&program_id, &mint_key, "0.20").unwrap(), vec![&mut mint_account], + &[Check::success(), Check::return_data(&20u64.to_le_bytes())], ) .unwrap(); - set_expected_data(20u64.to_le_bytes().to_vec()); do_process_instruction( ui_amount_to_amount(&program_id, &mint_key, "0.2000").unwrap(), vec![&mut mint_account], + &[Check::success(), Check::return_data(&20u64.to_le_bytes())], ) .unwrap(); - set_expected_data(20u64.to_le_bytes().to_vec()); do_process_instruction( ui_amount_to_amount(&program_id, &mint_key, ".20").unwrap(), vec![&mut mint_account], + &[Check::success(), Check::return_data(&20u64.to_le_bytes())], ) .unwrap(); - set_expected_data(110u64.to_le_bytes().to_vec()); do_process_instruction( ui_amount_to_amount(&program_id, &mint_key, "1.1").unwrap(), vec![&mut mint_account], + &[Check::success(), Check::return_data(&110u64.to_le_bytes())], ) .unwrap(); - set_expected_data(110u64.to_le_bytes().to_vec()); do_process_instruction( ui_amount_to_amount(&program_id, &mint_key, "1.10").unwrap(), vec![&mut mint_account], + &[Check::success(), Check::return_data(&110u64.to_le_bytes())], ) .unwrap(); - set_expected_data(4200u64.to_le_bytes().to_vec()); do_process_instruction( ui_amount_to_amount(&program_id, &mint_key, "42").unwrap(), vec![&mut mint_account], + &[Check::success(), Check::return_data(&4200u64.to_le_bytes())], ) .unwrap(); - set_expected_data(4200u64.to_le_bytes().to_vec()); do_process_instruction( ui_amount_to_amount(&program_id, &mint_key, "42.").unwrap(), vec![&mut mint_account], + &[Check::success(), Check::return_data(&4200u64.to_le_bytes())], ) .unwrap(); - set_expected_data(0u64.to_le_bytes().to_vec()); do_process_instruction( ui_amount_to_amount(&program_id, &mint_key, "0").unwrap(), vec![&mut mint_account], + &[Check::success(), Check::return_data(&0u64.to_le_bytes())], ) .unwrap(); @@ -5680,6 +6276,7 @@ fn test_ui_amount_to_amount() { do_process_instruction( ui_amount_to_amount(&program_id, &mint_key, "").unwrap(), vec![&mut mint_account], + &[Check::err(ProgramError::InvalidArgument)], ) ); assert_eq!( @@ -5687,6 +6284,7 @@ fn test_ui_amount_to_amount() { do_process_instruction( ui_amount_to_amount(&program_id, &mint_key, ".").unwrap(), vec![&mut mint_account], + &[Check::err(ProgramError::InvalidArgument)], ) ); assert_eq!( @@ -5694,6 +6292,7 @@ fn test_ui_amount_to_amount() { do_process_instruction( ui_amount_to_amount(&program_id, &mint_key, "0.111").unwrap(), vec![&mut mint_account], + &[Check::err(ProgramError::InvalidArgument)], ) ); assert_eq!( @@ -5701,6 +6300,7 @@ fn test_ui_amount_to_amount() { do_process_instruction( ui_amount_to_amount(&program_id, &mint_key, "0.t").unwrap(), vec![&mut mint_account], + &[Check::err(ProgramError::InvalidArgument)], ) ); } diff --git a/program/tests/setup.rs b/program/tests/setup.rs index df79381..4365dea 100644 --- a/program/tests/setup.rs +++ b/program/tests/setup.rs @@ -2,10 +2,7 @@ use { solana_sdk::{ - account::{Account as SolanaAccount, AccountSharedData}, - program_pack::Pack, - pubkey::Pubkey, - rent::Rent, + account::Account as SolanaAccount, program_pack::Pack, pubkey::Pubkey, rent::Rent, }, spl_token::state::{Account, AccountState, Mint}, }; @@ -15,7 +12,7 @@ pub fn setup_mint_account( freeze_authority: Option<&Pubkey>, supply: u64, decimals: u8, -) -> AccountSharedData { +) -> SolanaAccount { let data = { let mut data = vec![0; Mint::LEN]; let state = Mint { @@ -32,15 +29,15 @@ pub fn setup_mint_account( let space = data.len(); let lamports = Rent::default().minimum_balance(space); - AccountSharedData::from(SolanaAccount { + SolanaAccount { lamports, data, owner: spl_token::id(), ..Default::default() - }) + } } -pub fn setup_token_account(mint: &Pubkey, owner: &Pubkey, amount: u64) -> AccountSharedData { +pub fn setup_token_account(mint: &Pubkey, owner: &Pubkey, amount: u64) -> SolanaAccount { let data = { let mut data = vec![0; Account::LEN]; let state = Account { @@ -60,10 +57,10 @@ pub fn setup_token_account(mint: &Pubkey, owner: &Pubkey, amount: u64) -> Accoun let space = data.len(); let lamports = Rent::default().minimum_balance(space); - AccountSharedData::from(SolanaAccount { + SolanaAccount { lamports, data, owner: spl_token::id(), ..Default::default() - }) + } }