Get sendUnsuccessful.height from error

this makes parallel testing more stable
This commit is contained in:
Simon Warta
2020-06-08 10:22:46 +02:00
parent da8af6f5ae
commit a504d1a3c6
4 changed files with 24 additions and 18 deletions
@@ -1,5 +1,6 @@
/* eslint-disable @typescript-eslint/camelcase */
import { Coin, CosmosSdkTx, isMsgSend, makeSignBytes, MsgSend, Secp256k1Pen } from "@cosmjs/sdk38";
import { Uint53 } from "@iov/encoding";
import { assert, sleep } from "@iov/utils";
import { CosmWasmClient } from "./cosmwasmclient";
@@ -112,20 +113,22 @@ describe("CosmWasmClient.searchTx", () => {
},
};
const transactionId = await client.getIdentifier(tx);
const heightBeforeThis = await client.getHeight();
try {
await client.postTx(tx.value);
} catch (error) {
// postTx() throws on execution failures, which is a questionable design. Ignore for now.
// console.log(error);
const errorMessage: string = error.toString();
const [_, heightMatch] = errorMessage.match(/at height ([0-9]+)/) || ["", ""];
sendUnsuccessful = {
sender: alice.address0,
recipient: recipient,
hash: transactionId,
height: Uint53.fromString(heightMatch).toNumber(),
tx: tx,
};
}
sendUnsuccessful = {
sender: alice.address0,
recipient: recipient,
hash: transactionId,
height: heightBeforeThis + 1,
tx: tx,
};
}
{
+1 -1
View File
@@ -296,7 +296,7 @@ export class CosmWasmClient {
if (result.code) {
throw new Error(
`Error when posting tx ${result.txhash}. Code: ${result.code}; Raw log: ${result.raw_log}`,
`Error when posting tx ${result.txhash} at height ${result.height}. Code: ${result.code}; Raw log: ${result.raw_log}`,
);
}
@@ -1,4 +1,5 @@
/* eslint-disable @typescript-eslint/camelcase */
import { Uint53 } from "@iov/encoding";
import { assert, sleep } from "@iov/utils";
import { Coin } from "./coins";
@@ -104,20 +105,22 @@ describe("CosmosClient.searchTx", () => {
},
};
const transactionId = await client.getIdentifier(tx);
const heightBeforeThis = await client.getHeight();
try {
await client.postTx(tx.value);
} catch (error) {
// postTx() throws on execution failures, which is a questionable design. Ignore for now.
// console.log(error);
const errorMessage: string = error.toString();
const [_, heightMatch] = errorMessage.match(/at height ([0-9]+)/) || ["", ""];
sendUnsuccessful = {
sender: faucet.address,
recipient: recipient,
hash: transactionId,
height: Uint53.fromString(heightMatch).toNumber(),
tx: tx,
};
}
sendUnsuccessful = {
sender: faucet.address,
recipient: recipient,
hash: transactionId,
height: heightBeforeThis + 1,
tx: tx,
};
}
}
});
+1 -1
View File
@@ -278,7 +278,7 @@ export class CosmosClient {
if (result.code) {
throw new Error(
`Error when posting tx ${result.txhash}. Code: ${result.code}; Raw log: ${result.raw_log}`,
`Error when posting tx ${result.txhash} at height ${result.height}. Code: ${result.code}; Raw log: ${result.raw_log}`,
);
}