Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/installBundle/installBundle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@
}

for (let i = 0; i < chunks.length; i += 1) {
await new Promise(resolve => setTimeout(resolve, 15_000));

Check failure on line 188 in src/installBundle/installBundle.ts

View workflow job for this annotation

GitHub Actions / unit

Replace `resolve` with `(resolve)`
const chunk = chunks[i];
const proposalMsg = makeSendChunkMsg({
chunkedArtifactId,
Expand Down
9 changes: 8 additions & 1 deletion src/lib/signAndBroadcast.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ vi.mock("@paralleldrive/cuid2", () => ({
}));

describe("makeSignAndBroadcast Unit Tests", () => {
let mockStargateClient: { simulate: Mock; signAndBroadcast: Mock };
let mockStargateClient: {
simulate: Mock;
signAndBroadcast: Mock;
getTx: Mock;
};
let walletAddress: string;
let netName: string;
let proposalMsg: EncodeObject;
Expand All @@ -28,6 +32,7 @@ describe("makeSignAndBroadcast Unit Tests", () => {
mockStargateClient = {
simulate: vi.fn(),
signAndBroadcast: vi.fn(),
getTx: vi.fn(),
};

walletAddress = "agoric12345";
Expand All @@ -45,11 +50,13 @@ describe("makeSignAndBroadcast Unit Tests", () => {
const MOCK_GAS = 1000;
const mockTxResult = {
code: 0,
transactionHash: "DEADBEEF",
events: [],
};

mockStargateClient.simulate.mockResolvedValue(MOCK_GAS);
mockStargateClient.signAndBroadcast.mockResolvedValue(mockTxResult);
mockStargateClient.getTx.mockResolvedValue({ code: 0 });

const signAndBroadcast = makeSignAndBroadcast(
// @ts-expect-error mock stargateClient
Expand Down
20 changes: 20 additions & 0 deletions src/lib/signAndBroadcast.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,27 @@
[proposalMsg],
makeFeeObject({ gas }),
);
console.info('txResult', txResult);

Check failure on line 44 in src/lib/signAndBroadcast.tsx

View workflow job for this annotation

GitHub Actions / unit

Replace `'txResult'` with `"txResult"`
assertIsDeliverTxSuccess(txResult);
// Poll until the node confirms the transaction is indexed, so that
// state changes from this block are available for subsequent simulate/
// execute calls (e.g. chunk submissions after a manifest).
const { transactionHash } = txResult;
const pollIntervalMs = 1_000;
const maxAttempts = 30;
for (let i = 0; i < maxAttempts; i++) {
const indexed = await stargateClient.getTx(transactionHash);
console.info('IndexedTx', indexed);

Check failure on line 54 in src/lib/signAndBroadcast.tsx

View workflow job for this annotation

GitHub Actions / unit

Replace `'IndexedTx'` with `"IndexedTx"`
if (indexed) {
if (indexed.code !== 0) {
throw new Error(
`Transaction ${transactionHash} failed on-chain with code ${indexed.code}`,
);
}
break;
}
await new Promise((resolve) => setTimeout(resolve, pollIntervalMs));
}
} catch (e) {
toast.update(toastId, {
render: parseError(e as Error),
Expand Down
Loading