Skip to content

Commit

Permalink
fix: unbreak the fake-chain
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelfig committed Mar 11, 2020
1 parent 01ba947 commit d84ee30
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions packages/cosmic-swingset/lib/ag-solo/fake-chain.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export async function connectToFakeChain(basedir, GCI, role, delay, inbound) {
const argv = [`--role=${role}`, bootAddress];
const stateDBdir = path.join(basedir, `fake-chain-${GCI}-state`);
const s = await launch(stateDBdir, mailboxStorage, vatsdir, argv);
const { deliverInbound, deliverStartBlock } = s;
const { deliverInbound, beginBlock, saveChainState, saveOutsideState } = s;

let pretendLast = Date.now();
let blockHeight = 0;
Expand All @@ -51,13 +51,15 @@ export async function connectToFakeChain(basedir, GCI, role, delay, inbound) {
try {
const commitStamp = pretendLast + PRETEND_BLOCK_DELAY * 1000;
const blockTime = Math.floor(commitStamp / 1000);
await deliverStartBlock(blockHeight, blockTime, true);
await beginBlock(blockHeight, blockTime);
for (let i = 0; i < thisBlock.length; i += 1) {
const [newMessages, acknum] = thisBlock[i];
await deliverInbound(bootAddress, newMessages, acknum, true);
await deliverInbound(bootAddress, newMessages, acknum);
}

// Done processing, "commit the block".
saveChainState();
saveOutsideState();
await writeMap(mailboxFile, mailboxStorage);
thisBlock = [];
pretendLast = commitStamp + Date.now() - actualStart;
Expand Down

0 comments on commit d84ee30

Please sign in to comment.