Skip to content

Commit

Permalink
chore(test): send channelOpenAck immediately
Browse files Browse the repository at this point in the history
- some contracts rely on ICAs to be created before a `StartFn` completes
- this change faciliates that while preserving the ability to control the settlement of other DIBC bridge messages
  • Loading branch information
0xpatrickdev committed Dec 5, 2024
1 parent 8694aed commit 0ad8d7d
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 52 deletions.
15 changes: 3 additions & 12 deletions packages/boot/test/bootstrapTests/orchestration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ test.serial('stakeAtom - smart wallet', async t => {
buildProposal,
evalProposal,
agoricNamesRemotes,
bridgeUtils: { flushInboundQueue },
readPublished,
harness,
} = t.context;
Expand All @@ -192,7 +191,6 @@ test.serial('stakeAtom - smart wallet', async t => {
harness && t.log('makeAccount computrons', harness.totalComputronCount());
harness?.useRunPolicy(false);

await flushInboundQueue();
t.like(wd.getCurrentWalletRecord(), {
offerToPublicSubscriberPaths: [
[
Expand Down Expand Up @@ -322,7 +320,7 @@ test.serial('basic-flows', async t => {
evalProposal,
agoricNamesRemotes,
readPublished,
bridgeUtils: { flushInboundQueue, runInbound },
bridgeUtils: { runInbound },
} = t.context;

await evalProposal(
Expand Down Expand Up @@ -372,7 +370,6 @@ test.serial('basic-flows', async t => {
},
proposal: {},
});
await flushInboundQueue();
t.like(wd.getCurrentWalletRecord(), {
offerToPublicSubscriberPaths: [
[
Expand Down Expand Up @@ -539,13 +536,8 @@ test.serial('auto-stake-it - proposal', async t => {
});

test.serial('basic-flows - portfolio holder', async t => {
const {
buildProposal,
evalProposal,
readPublished,
agoricNamesRemotes,
bridgeUtils: { flushInboundQueue },
} = t.context;
const { buildProposal, evalProposal, readPublished, agoricNamesRemotes } =
t.context;

await evalProposal(
buildProposal(
Expand Down Expand Up @@ -592,7 +584,6 @@ test.serial('basic-flows - portfolio holder', async t => {
},
'trivially satisfied',
);
await flushInboundQueue();
t.like(wd.getCurrentWalletRecord(), {
offerToPublicSubscriberPaths: [
[
Expand Down
60 changes: 21 additions & 39 deletions packages/boot/test/orchestration/restart-contracts.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,6 @@ test.serial('stakeAtom', async t => {
});
// cosmos1test is from ibc/mocks.js
const accountPath = 'published.stakeAtom.accounts.cosmos1test';
t.throws(() => readLatest(accountPath));
t.is(await flushInboundQueue(), 1);
t.deepEqual(readLatest(accountPath), {
localAddress:
'/ibc-port/icacontroller-1/ordered/{"version":"ics27-1","controllerConnectionId":"connection-8","hostConnectionId":"connection-649","address":"cosmos1test","encoding":"proto3","txType":"sdk_multi_msg"}/ibc-channel/channel-1',
Expand Down Expand Up @@ -205,7 +203,7 @@ test.serial('stakeAtom', async t => {
// to fresh contract state on each iteration, and since this is a bootstrap test
// that means either restarting bootstrap or starting a new contract and
// restarting that one. For them to share bootstrap they'll each need a unique
// instance name, which will require paramatizing the the two builders scripts
// instance name, which will require parameterizing the the two builders scripts
// and the two core-eval functions.
test.serial('basicFlows', async t => {
const {
Expand All @@ -222,10 +220,9 @@ test.serial('basicFlows', async t => {

t.log('making offer');
const wallet = await walletFactoryDriver.provideSmartWallet('agoric1test');
const id1 = 'make-orch-account';
// send because it won't resolve
const id = 'makePortfolio';
await wallet.sendOffer({
id: id1,
id,
invitationSpec: {
source: 'agoricContract',
instancePath: ['basicFlows'],
Expand All @@ -236,43 +233,36 @@ test.serial('basicFlows', async t => {
chainName: 'cosmoshub',
},
});
// no errors and no result yet
t.like(wallet.getLatestUpdateRecord(), {
status: {
id: id1,
id,
error: undefined,
numWantsSatisfied: 1,
payouts: {},
result: undefined, // no property
result: 'UNPUBLISHED', // continuing offer result
},
});
t.is(getInboundQueueLength(), 1);

const id2 = 'makePortfolio';
// send because it won't resolve
const transferId = 'ibc-transfer';
await wallet.sendOffer({
id: id2,
id: transferId,
invitationSpec: {
source: 'agoricContract',
instancePath: ['basicFlows'],
callPipe: [['makePortfolioAccountInvitation']],
source: 'continuing',
previousOffer: id,
invitationMakerName: 'Transfer',
},
proposal: {},
offerArgs: {
chainNames: ['agoric', 'cosmoshub', 'osmosis'],
},
});
// no errors and no result yet
t.like(wallet.getLatestUpdateRecord(), {
status: {
id: id2,
error: undefined,
numWantsSatisfied: 1,
payouts: {},
result: undefined, // no property
amount: { denom: ATOM_DENOM, value: 10n },
destination: {
chainId: 'osmosis-1',
value: 'osmosis1test',
encoding: 'bech32,',
},
},
});
// 3x ICA Channel Opens, 1x ICQ Channel Open
t.is(getInboundQueueLength(), 4);
t.is(getInboundQueueLength(), 1);

t.log('restart basicFlows');
await evalProposal(
Expand All @@ -286,20 +276,12 @@ test.serial('basicFlows', async t => {
result: undefined,
},
});
t.is(await flushInboundQueue(1), 1);
t.like(wallet.getLatestUpdateRecord(), {
status: {
id: id1,
error: undefined,
result: 'UNPUBLISHED',
},
});
t.is(await flushInboundQueue(3), 3);
t.is(await flushInboundQueue(), 1);
t.like(wallet.getLatestUpdateRecord(), {
status: {
id: id2,
id: transferId,
error: undefined,
result: 'UNPUBLISHED',
result: undefined, // no property
},
});
});
5 changes: 5 additions & 0 deletions packages/boot/tools/ibc/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ export const protoMsgMocks = {
msg: 'eyJ0eXBlIjoxLCJkYXRhIjoiQ25zS0tTOXBZbU11WVhCd2JHbGpZWFJwYjI1ekxuUnlZVzV6Wm1WeUxuWXhMazF6WjFSeVlXNXpabVZ5RWs0S0NIUnlZVzV6Wm1WeUVndGphR0Z1Ym1Wc0xUVXpOaG9UQ2cxcFltTXZkWFZ6WkdOb1lYTm9FZ0l4TUNJTFkyOXpiVzl6TVhSbGMzUXFDbTV2WW14bE1YUmxjM1F5QURpQThKTEwzUWc9IiwibWVtbyI6IiJ9',
ack: responses.ibcTransfer,
},
// MsgTransfer 10 uatom from cosmos1test to osmosis1test through channel-141
ibcTransfer2: {
msg: 'eyJ0eXBlIjoxLCJkYXRhIjoiQ25VS0tTOXBZbU11WVhCd2JHbGpZWFJwYjI1ekxuUnlZVzV6Wm1WeUxuWXhMazF6WjFSeVlXNXpabVZ5RWtnS0NIUnlZVzV6Wm1WeUVndGphR0Z1Ym1Wc0xURTBNUm9MQ2dWMVlYUnZiUklDTVRBaUMyTnZjMjF2Y3pGMFpYTjBLZ3h2YzIxdmMybHpNWFJsYzNReUFEaUE4SkxMM1FnPSIsIm1lbW8iOiIifQ==',
ack: responses.ibcTransfer,
},
error: {
msg: '',
ack: responses.error5,
Expand Down
2 changes: 1 addition & 1 deletion packages/boot/tools/supports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ export const makeSwingsetTestKit = async (
case `${BridgeId.VTRANSFER}:IBC_METHOD`: {
switch (obj.method) {
case 'startChannelOpenInit':
pushInbound(BridgeId.DIBC, icaMocks.channelOpenAck(obj));
inbound(BridgeId.DIBC, icaMocks.channelOpenAck(obj));
return undefined;
case 'sendPacket': {
if (protoMsgMockMap[obj.packet.data]) {
Expand Down

0 comments on commit 0ad8d7d

Please sign in to comment.