11import { toBase64 } from '@cosmjs/encoding' ;
22import fs from 'fs' ;
33import { CWSimulateApp } from './CWSimulateApp' ;
4+ import * as persist from './persist' ;
5+ import { TestContract } from '../testing/wasm-util' ;
46
57const bytecode = fs . readFileSync ( './testing/cw_simulate_tests-aarch64.wasm' ) ;
68
@@ -11,7 +13,11 @@ describe('de/serialize', () => {
1113 ref . wasm . create ( 'alice' , bytecode ) ;
1214 ref . wasm . create ( 'bob' , bytecode ) ;
1315
14- const clone = CWSimulateApp . deserialize ( ref . serialize ( ) ) ;
16+ const response = await ref . wasm . instantiateContract ( 'alice' , [ ] , 1 , { } , '' ) ;
17+ const address = response . unwrap ( ) . events [ 0 ] . attributes [ 0 ] . value ;
18+
19+ const bytes = persist . save ( ref ) ;
20+ const clone = await persist . load ( bytes ) ;
1521 expect ( clone . chainId ) . toStrictEqual ( ref . chainId ) ;
1622 expect ( clone . bech32Prefix ) . toStrictEqual ( ref . bech32Prefix ) ;
1723
@@ -21,6 +27,9 @@ describe('de/serialize', () => {
2127 expect ( code2 . creator ) . toStrictEqual ( 'bob' ) ;
2228 expect ( toBase64 ( code1 . wasmCode ) ) . toStrictEqual ( toBase64 ( ref . wasm . store . getObject ( 'codes' , 1 , 'wasmCode' ) ) ) ;
2329 expect ( toBase64 ( code2 . wasmCode ) ) . toStrictEqual ( toBase64 ( ref . wasm . store . getObject ( 'codes' , 2 , 'wasmCode' ) ) ) ;
30+
31+ let result = await clone . wasm . executeContract ( 'alice' , [ ] , address , { debug : { msg : 'foobar' } } ) ;
32+ expect ( result . ok ) . toBeTruthy ( ) ;
2433 }
2534 } )
2635} )
0 commit comments