Skip to content

Commit

Permalink
fix provision partial on deploy cancel
Browse files Browse the repository at this point in the history
fixes #401
  • Loading branch information
dbeal-eth committed Sep 2, 2023
1 parent 306fa2a commit 00e8fb7
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ packages/contracts/lib/forge-std
packages/contracts/lib/openzeppelin-contracts
packages/website/next.config.js
packages/website/src/types/graphql/*
packages/website/.next
packages/*/dist
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ artifacts
cache
coverage*
gasReporterOutput.json
dist
.next
56 changes: 55 additions & 1 deletion packages/builder/src/steps/provision.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,61 @@ describe('steps/provision.ts', () => {
).rejects.toThrowError('deployment not found');
});

it('works properly', async () => {
it('returns partial deployment if runtime becomes cancelled', async () => {
await registry.publish(['hello:1.0.0'], '1234-main', 'https://something.com', '');

jest.mocked(fakeRuntime.readDeploy).mockResolvedValue({
generator: 'cannon test',
timestamp: 1234,
state: {
'contract.Woot': {
version: BUILD_VERSION,
hash: 'arst',
artifacts: {
contracts: {
Woot: {
address: '0xfoobar',
abi: [],
deployTxnHash: '0x',
contractName: 'Woot',
sourceName: 'Woot.sol',
deployedOn: 'contract.Woot',
},
},
},
},
},
options: {},
def: {
name: 'hello',
version: '1.0.0',
contract: {
Woot: { artifact: 'Woot' },
},
} as any,
meta: {},
miscUrl: 'https://something.com',
});

jest.mocked(fakeRuntime.putDeploy).mockResolvedValue('ipfs://Qmsomething');
jest.mocked(fakeRuntime.isCancelled).mockReturnValue(true);
console.log('is c ancel', fakeRuntime.isCancelled());

const result = await action.exec(
fakeRuntime,
fakeCtx,
{ source: 'hello:1.0.0' },
{ name: 'package', version: '1.0.0', currentLabel: 'import.something' }
);

expect(result.imports!['something'].url).toEqual('ipfs://Qmsomething');

expect(jest.mocked(fakeRuntime.putDeploy).mock.calls[0][0].status).toEqual('partial');

jest.mocked(fakeRuntime.isCancelled).mockReturnValue(false);
});

it('works with complete deployment', async () => {
await registry.publish(['hello:1.0.0'], '1234-main', 'https://something.com', '');

jest.mocked(fakeRuntime.readDeploy).mockResolvedValue({
Expand Down
4 changes: 4 additions & 0 deletions packages/builder/src/steps/provision.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,10 @@ export default {

debug('start build');
const builtState = await build(importRuntime, def, prevState, initialCtx);
if (importRuntime.isCancelled()) {
partialDeploy = true;
}

debug('finish build. is partial:', partialDeploy);

const newMiscUrl = await importRuntime.recordMisc();
Expand Down

0 comments on commit 00e8fb7

Please sign in to comment.