mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-18 17:35:42 +00:00
Fix contracts instantiation (#51)
* Move contracts tests to contracts module * Add test for instantiating a contract * Fix InstantiateArgs encoding * Ignore PhantomData primitives, they are 0 * Increase endowment and log code hash * Update SystemEvent * Fix codec import * Oops * Write buffer directly to output to avoid encoding vec * Debug with StorageChanges encoded as hex * Logging and format code
This commit is contained in:
+1
-36
@@ -421,7 +421,7 @@ mod tests {
|
||||
type Address = <Runtime as System>::Address;
|
||||
type Balance = <Runtime as Balances>::Balance;
|
||||
|
||||
fn test_setup() -> (tokio::runtime::Runtime, Client<Runtime>) {
|
||||
pub(crate) fn test_setup() -> (tokio::runtime::Runtime, Client<Runtime>) {
|
||||
env_logger::try_init().ok();
|
||||
let mut rt = tokio::runtime::Runtime::new().unwrap();
|
||||
let client_future = ClientBuilder::<Runtime>::new().build();
|
||||
@@ -450,41 +450,6 @@ mod tests {
|
||||
rt.block_on(transfer).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore] // requires locally running substrate node
|
||||
fn test_tx_contract_put_code() {
|
||||
let (mut rt, client) = test_setup();
|
||||
|
||||
let signer = AccountKeyring::Alice.pair();
|
||||
let xt = rt.block_on(client.xt(signer, None)).unwrap();
|
||||
|
||||
const CONTRACT: &str = r#"
|
||||
(module
|
||||
(func (export "call"))
|
||||
(func (export "deploy"))
|
||||
)
|
||||
"#;
|
||||
let wasm = wabt::wat2wasm(CONTRACT).expect("invalid wabt");
|
||||
|
||||
let put_code = xt.submit_and_watch(contracts::put_code(500_000, wasm));
|
||||
|
||||
let success = rt
|
||||
.block_on(put_code)
|
||||
.expect("Extrinsic should be included in a block");
|
||||
|
||||
let code_hash =
|
||||
success.find_event::<<Runtime as System>::Hash>("Contracts", "CodeStored");
|
||||
|
||||
assert!(
|
||||
code_hash.is_some(),
|
||||
"Contracts CodeStored event should be present"
|
||||
);
|
||||
assert!(
|
||||
code_hash.unwrap().is_ok(),
|
||||
"CodeStored Hash should decode successfully"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore] // requires locally running substrate node
|
||||
fn test_getting_hash() {
|
||||
|
||||
Reference in New Issue
Block a user