From cbdf45c1ad3994937edeebb149b7f3807c23c133 Mon Sep 17 00:00:00 2001 From: Leigh McCulloch <351529+leighmcculloch@users.noreply.github.com> Date: Thu, 31 Oct 2024 10:57:55 +1000 Subject: [PATCH] add test vector --- Cargo.lock | 8 + tests/deploy/Cargo.toml | 19 ++ tests/deploy/src/lib.rs | 38 +++ .../test_snapshots/test/test_deploy.1.json | 252 ++++++++++++++++++ 4 files changed, 317 insertions(+) create mode 100644 tests/deploy/Cargo.toml create mode 100644 tests/deploy/src/lib.rs create mode 100644 tests/deploy/test_snapshots/test/test_deploy.1.json diff --git a/Cargo.lock b/Cargo.lock index fe6606ed..6a1c614b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1534,6 +1534,14 @@ dependencies = [ "soroban-sdk", ] +[[package]] +name = "test_deploy" +version = "22.0.0-rc.3" +dependencies = [ + "soroban-sdk", + "test_constructor", +] + [[package]] name = "test_empty" version = "22.0.0-rc.3" diff --git a/tests/deploy/Cargo.toml b/tests/deploy/Cargo.toml new file mode 100644 index 00000000..699f4778 --- /dev/null +++ b/tests/deploy/Cargo.toml @@ -0,0 +1,19 @@ +[package] +name = "test_deploy" +version.workspace = true +authors = ["Stellar Development Foundation "] +license = "Apache-2.0" +edition = "2021" +publish = false +rust-version.workspace = true + +[lib] +crate-type = ["cdylib"] +doctest = false + +[dependencies] +soroban-sdk = {path = "../../soroban-sdk"} +test_constructor = {path = "../constructor"} + +[dev-dependencies] +soroban-sdk = {path = "../../soroban-sdk", features = ["testutils"]} diff --git a/tests/deploy/src/lib.rs b/tests/deploy/src/lib.rs new file mode 100644 index 00000000..49b715a8 --- /dev/null +++ b/tests/deploy/src/lib.rs @@ -0,0 +1,38 @@ +#![no_std] +use soroban_sdk::{contract, contractimpl, BytesN, Env}; + +mod deployable { + soroban_sdk::contractimport!( + file = "../../target/wasm32-unknown-unknown/release/test_constructor.wasm" + ); +} + +#[contract] +pub struct Contract; + +#[contractimpl] +impl Contract { + pub fn deploy(env: &Env) { + let hash = env.deployer().upload_contract_wasm(deployable::WASM); + env.deployer() + .with_current_contract(BytesN::from_array(env, &[0; 32])) + .deploy_v2(hash, deployable::Args::__constructor(&1, &2)); + // .deploy_v2(hash, (1u32, 2u64)); + } +} + +#[cfg(test)] +mod test { + use soroban_sdk::Env; + + use crate::{Contract, ContractClient}; + + #[test] + fn test_deploy() { + let e = Env::default(); + let contract_id = e.register(Contract, ()); + let client = ContractClient::new(&e, &contract_id); + + client.deploy(); + } +} diff --git a/tests/deploy/test_snapshots/test/test_deploy.1.json b/tests/deploy/test_snapshots/test/test_deploy.1.json new file mode 100644 index 00000000..3f08054f --- /dev/null +++ b/tests/deploy/test_snapshots/test/test_deploy.1.json @@ -0,0 +1,252 @@ +{ + "generators": { + "address": 1, + "nonce": 0 + }, + "auth": [ + [], + [] + ], + "ledger": { + "protocol_version": 22, + "sequence_number": 0, + "timestamp": 0, + "network_id": "0000000000000000000000000000000000000000000000000000000000000000", + "base_reserve": 0, + "min_persistent_entry_ttl": 4096, + "min_temp_entry_ttl": 16, + "max_entry_ttl": 6312000, + "ledger_entries": [ + [ + { + "contract_data": { + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": "ledger_key_contract_instance", + "durability": "persistent" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": "ledger_key_contract_instance", + "durability": "persistent", + "val": { + "contract_instance": { + "executable": { + "wasm": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "storage": null + } + } + } + }, + "ext": "v0" + }, + 4095 + ] + ], + [ + { + "contract_data": { + "contract": "CBKMUZNFQIAL775XBB2W2GP5CNHBM5YGH6C3XB7AY6SUVO2IBU3VYK2V", + "key": { + "vec": [ + { + "symbol": "Persistent" + }, + { + "u32": 1 + } + ] + }, + "durability": "persistent" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CBKMUZNFQIAL775XBB2W2GP5CNHBM5YGH6C3XB7AY6SUVO2IBU3VYK2V", + "key": { + "vec": [ + { + "symbol": "Persistent" + }, + { + "u32": 1 + } + ] + }, + "durability": "persistent", + "val": { + "i64": 2 + } + } + }, + "ext": "v0" + }, + 4095 + ] + ], + [ + { + "contract_data": { + "contract": "CBKMUZNFQIAL775XBB2W2GP5CNHBM5YGH6C3XB7AY6SUVO2IBU3VYK2V", + "key": { + "vec": [ + { + "symbol": "Temp" + }, + { + "u32": 2 + } + ] + }, + "durability": "temporary" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CBKMUZNFQIAL775XBB2W2GP5CNHBM5YGH6C3XB7AY6SUVO2IBU3VYK2V", + "key": { + "vec": [ + { + "symbol": "Temp" + }, + { + "u32": 2 + } + ] + }, + "durability": "temporary", + "val": { + "i64": 4 + } + } + }, + "ext": "v0" + }, + 15 + ] + ], + [ + { + "contract_data": { + "contract": "CBKMUZNFQIAL775XBB2W2GP5CNHBM5YGH6C3XB7AY6SUVO2IBU3VYK2V", + "key": "ledger_key_contract_instance", + "durability": "persistent" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CBKMUZNFQIAL775XBB2W2GP5CNHBM5YGH6C3XB7AY6SUVO2IBU3VYK2V", + "key": "ledger_key_contract_instance", + "durability": "persistent", + "val": { + "contract_instance": { + "executable": { + "wasm": "81b9295b1200c352b05ca3614256d595a4b221361c560f4b0610cbf0e8931cc2" + }, + "storage": [ + { + "key": { + "vec": [ + { + "symbol": "Instance" + }, + { + "u32": 3 + } + ] + }, + "val": { + "i64": 6 + } + } + ] + } + } + } + }, + "ext": "v0" + }, + 4095 + ] + ], + [ + { + "contract_code": { + "hash": "81b9295b1200c352b05ca3614256d595a4b221361c560f4b0610cbf0e8931cc2" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_code": { + "ext": { + "v1": { + "ext": "v0", + "cost_inputs": { + "ext": "v0", + "n_instructions": 733, + "n_functions": 15, + "n_globals": 3, + "n_table_entries": 0, + "n_types": 12, + "n_data_segments": 1, + "n_elem_segments": 0, + "n_imports": 10, + "n_exports": 6, + "n_data_segment_bytes": 48 + } + } + }, + "hash": "81b9295b1200c352b05ca3614256d595a4b221361c560f4b0610cbf0e8931cc2", + "code": "0061736d0100000001470c60017e017e60037e7e7e017e60027e7e017e60027f7e0060047f7f7e7e0060027f7f017e60037f7e7e0060000060027f7f0060027f7f017f60027e7e017f60057f7e7e7e7e00023d0a016901320000016901310000016c015f00010176013300000162016d0001016c013100020176013100020176016700020162016a0002016c0130000203100f03000405050602070008090a07070b05030100110619037f01418080c0000b7f0041b080c0000b7f0041b080c0000b074406066d656d6f727902000d5f5f636f6e7374727563746f720010086765745f646174610012015f00170a5f5f646174615f656e6403010b5f5f686561705f6261736503020a910d0f5d02017f017e024002402001a741ff0171220241c100460d00024020024107460d00420121034283908080800121010c020b20014208872101420021030c010b42002103200110808080800021010b20002001370308200020033703000b2f00024020004280808080808080407c4280808080808080807f540d0020004208864207840f0b20001081808080000b1d0020002001108d808080002002108b8080800020031082808080001a0b980102017f027e23808080800041106b22022480808080002001ad4220864204842103024002400240024020000e03000102000b418080c08000410a108e8080800021040c020b418a80c080004104108e8080800021040c010b418e80c080004108108e8080800021040b200220042003108f8080800002402002290300a7450d0000000b20022903082103200241106a24808080800020030bc60102017e047f0240200141094b0d00420021022001210320002104024003402003450d0141012105024020042d0000220641df00460d000240200641506a41ff0171410a490d000240200641bf7f6a41ff0171411a490d002006419f7f6a41ff017141194b0d05200641456a21050c020b2006414b6a21050c010b200641526a21050b20024206862005ad42ff01838421022003417f6a2103200441016a21040c000b0b2002420886420e840f0b2000ad4220864204842001ad4220864204841088808080000b4f01017f23808080800041106b2203248080808000200320023703082003200137030020002003ad42208642048442848080802010878080800037030820004200370300200341106a2480808080000bda0101027f23808080800041206b220224808080800002400240200042ff01834204520d00200241106a2001108a8080800020022802100d0041002000422088a72203200229031822014201108c8080800020004200530d012001428080808080808080c0007c4200530d014101200341017420014201864200108c808080002003ad42037e2200422088a70d01200220012001423f8742034200109880808000200229030820022903002201423f87520d0141022000a720014202108c80808000200241206a24808080800042020f0b00000b109180808000000b0900109680808000000bd50403017f017e017f2380808080004180016b22012480808080000240200042ff018342cb00520d00200010838080800021022001410036027820012000370370200120024220883e027c200141e0006a200141f0006a1093808080002001290360a70d00024020012903682200a741ff0171220341ca00460d002003410e470d010b024002400240024002402000419880c08000ad422086420484428480808030108480808000422088a70e03000102050b2001280278200128027c10948080800041014b0d04200141106a200141f0006a10938080800020012802100d042001290318220242ff01834204520d044202210041002002422088a7108d8080800022024201109580808000450d03200120024201108580808000108a808080002001290300a70d04200129030821000c020b2001280278200128027c10948080800041014b0d03200141306a200141f0006a10938080800020012802300d032001290338220242ff01834204520d034202210041012002422088a7108d8080800022024200109580808000450d02200141206a20024200108580808000108a808080002001290320a70d03200129032821000c010b2001280278200128027c10948080800041014b0d02200141d0006a200141f0006a10938080800020012802500d022001290358220242ff01834204520d024202210041022002422088a7108d8080800022024202109580808000450d01200141c0006a20024202108580808000108a808080002001290340a70d02200129034821000b2000108b8080800021000b20014180016a24808080800020000f0b00000b5302017f027e0240024020012802082202200128020c490d00420221030c010b20012903002002ad42208642048410868080800021042001200241016a360208420021030b20002004370308200020033703000b1900024020012000490d00200120006b0f0b109180808000000b0f00200020011089808080004201510b040000000b02000b6e01067e2000200342ffffffff0f832205200142ffffffff0f8322067e22072003422088220820067e22062005200142208822097e7c22054220867c220a3703002000200820097e2005200654ad4220862005422088847c200a200754ad7c200420017e200320027e7c7c3703080b0b390100418080c0000b3050657273697374656e7454656d70496e7374616e63650000000010000a0000000a001000040000000e00100008000000008f020e636f6e747261637473706563763000000002000000000000000000000007446174614b6579000000000300000001000000000000000a50657273697374656e740000000000010000000400000001000000000000000454656d700000000100000004000000010000000000000008496e7374616e6365000000010000000400000000000000000000000d5f5f636f6e7374727563746f72000000000000020000000000000008696e69745f6b657900000004000000000000000a696e69745f76616c7565000000000007000000000000000000000000000000086765745f646174610000000100000000000000036b657900000007d000000007446174614b65790000000001000003e800000007001e11636f6e7472616374656e766d6574617630000000000000001600000000007b0e636f6e74726163746d65746176300000000000000005727376657200000000000006312e38312e3000000000000000000008727373646b7665720000003a32322e302e302d72632e3323643136376565303636393930313031333835623664393164353564623263383332383837313163652d64697274790000" + } + }, + "ext": "v0" + }, + 4095 + ] + ], + [ + { + "contract_code": { + "hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_code": { + "ext": "v0", + "hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "code": "" + } + }, + "ext": "v0" + }, + 4095 + ] + ] + ] + }, + "events": [] +} \ No newline at end of file