Get sendUnsuccessful.height from error
this makes parallel testing more stable
This commit is contained in:
@@ -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,
|
||||
};
|
||||
}
|
||||
|
||||
{
|
||||
|
||||
@@ -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,
|
||||
};
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -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}`,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user