From 542939a63e45390946e8a9e8fa0e0ab00f3fbfa6 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Thu, 27 Feb 2020 23:12:57 +0100 Subject: [PATCH] Adapt code to latest hackatom --- packages/sdk/src/restclient.spec.ts | 2 +- packages/sdk/src/testutils.spec.ts | 15 +++++++-------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/packages/sdk/src/restclient.spec.ts b/packages/sdk/src/restclient.spec.ts index 72fd454b..b6c05d02 100644 --- a/packages/sdk/src/restclient.spec.ts +++ b/packages/sdk/src/restclient.spec.ts @@ -144,7 +144,7 @@ async function executeContract( value: { sender: faucet.address, contract: contractAddress, - msg: {}, + msg: { release: {} }, sent_funds: [], }, }; diff --git a/packages/sdk/src/testutils.spec.ts b/packages/sdk/src/testutils.spec.ts index f9278ec1..2126355c 100644 --- a/packages/sdk/src/testutils.spec.ts +++ b/packages/sdk/src/testutils.spec.ts @@ -27,19 +27,18 @@ export function leb128Encode(uint: number): Uint8Array { export function getRandomizedHackatom(): Uint8Array { const data = Encoding.fromBase64(hackatom.data); - // TODO: this needs to be redone! // The return value of the export function cosmwasm_api_0_6 is unused and // can be randomized for testing. // // Find position of mutable bytes as follows: // $ wasm-objdump -d contract.wasm | grep -F "cosmwasm_api_0_6" -A 1 - // 00e67c func[149] : - // 00e67d: 41 83 0c | i32.const 1539 + // 0136d2 func[198] : + // 0136d3: 41 83 0c | i32.const 1539 // - // In the last line, the addresses 00e67d-00e67f hold a one byte instruction - // (https://github.com/WebAssembly/design/blob/master/BinaryEncoding.md#constants-described-here) - // and a two byte value (leb128 encoded 1539) + // In the last line, the addresses [0136d3, 0136d3+1, 0136d3+2] hold a one byte instruction + // and a two byte value (leb128 encoded 1539). See also + // https://github.com/WebAssembly/design/blob/master/BinaryEncoding.md#constants-described-here. // Any unsigned integer from 128 to 16383 is encoded to two leb128 bytes const min = 128; @@ -47,8 +46,8 @@ export function getRandomizedHackatom(): Uint8Array { const random = Math.floor(Math.random() * (max - min)) + min; const bytes = leb128Encode(random); - data[0x00e67d + 1] = bytes[0]; - data[0x00e67d + 2] = bytes[1]; + data[0x0136d3 + 1] = bytes[0]; + data[0x0136d3 + 2] = bytes[1]; return data; }