Skip to content

Commit

Permalink
fix & improve serde integration test
Browse files Browse the repository at this point in the history
could use some more coverage tho...
  • Loading branch information
Kiruse committed Dec 19, 2022
1 parent 2ef53cb commit fa7aa92
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/CWSimulateApp.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { toBase64 } from '@cosmjs/encoding';
import fs from 'fs';
import { CWSimulateApp } from './CWSimulateApp';
import * as persist from './persist';
import { TestContract } from '../testing/wasm-util';

const bytecode = fs.readFileSync('./testing/cw_simulate_tests-aarch64.wasm');

Expand All @@ -11,7 +13,11 @@ describe('de/serialize', () => {
ref.wasm.create('alice', bytecode);
ref.wasm.create('bob', bytecode);

const clone = CWSimulateApp.deserialize(ref.serialize());
const response = await ref.wasm.instantiateContract('alice', [], 1, {}, '');
const address = response.unwrap().events[0].attributes[0].value;

const bytes = persist.save(ref);
const clone = await persist.load(bytes);
expect(clone.chainId).toStrictEqual(ref.chainId);
expect(clone.bech32Prefix).toStrictEqual(ref.bech32Prefix);

Expand All @@ -21,6 +27,9 @@ describe('de/serialize', () => {
expect(code2.creator).toStrictEqual('bob');
expect(toBase64(code1.wasmCode)).toStrictEqual(toBase64(ref.wasm.store.getObject('codes', 1, 'wasmCode')));
expect(toBase64(code2.wasmCode)).toStrictEqual(toBase64(ref.wasm.store.getObject('codes', 2, 'wasmCode')));

let result = await clone.wasm.executeContract('alice', [], address, { debug: { msg: 'foobar' }});
expect(result.ok).toBeTruthy();
}
})
})

0 comments on commit fa7aa92

Please sign in to comment.