Skip to content

Commit 00e8fb7

Browse files
committed
fix provision partial on deploy cancel
fixes usecannon#401
1 parent 306fa2a commit 00e8fb7

File tree

4 files changed

+63
-1
lines changed

4 files changed

+63
-1
lines changed

.eslintignore

+2
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,5 @@ packages/contracts/lib/forge-std
88
packages/contracts/lib/openzeppelin-contracts
99
packages/website/next.config.js
1010
packages/website/src/types/graphql/*
11+
packages/website/.next
12+
packages/*/dist

.prettierignore

+2
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@ artifacts
33
cache
44
coverage*
55
gasReporterOutput.json
6+
dist
7+
.next

packages/builder/src/steps/provision.test.ts

+55-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,61 @@ describe('steps/provision.ts', () => {
103103
).rejects.toThrowError('deployment not found');
104104
});
105105

106-
it('works properly', async () => {
106+
it('returns partial deployment if runtime becomes cancelled', async () => {
107+
await registry.publish(['hello:1.0.0'], '1234-main', 'https://something.com', '');
108+
109+
jest.mocked(fakeRuntime.readDeploy).mockResolvedValue({
110+
generator: 'cannon test',
111+
timestamp: 1234,
112+
state: {
113+
'contract.Woot': {
114+
version: BUILD_VERSION,
115+
hash: 'arst',
116+
artifacts: {
117+
contracts: {
118+
Woot: {
119+
address: '0xfoobar',
120+
abi: [],
121+
deployTxnHash: '0x',
122+
contractName: 'Woot',
123+
sourceName: 'Woot.sol',
124+
deployedOn: 'contract.Woot',
125+
},
126+
},
127+
},
128+
},
129+
},
130+
options: {},
131+
def: {
132+
name: 'hello',
133+
version: '1.0.0',
134+
contract: {
135+
Woot: { artifact: 'Woot' },
136+
},
137+
} as any,
138+
meta: {},
139+
miscUrl: 'https://something.com',
140+
});
141+
142+
jest.mocked(fakeRuntime.putDeploy).mockResolvedValue('ipfs://Qmsomething');
143+
jest.mocked(fakeRuntime.isCancelled).mockReturnValue(true);
144+
console.log('is c ancel', fakeRuntime.isCancelled());
145+
146+
const result = await action.exec(
147+
fakeRuntime,
148+
fakeCtx,
149+
{ source: 'hello:1.0.0' },
150+
{ name: 'package', version: '1.0.0', currentLabel: 'import.something' }
151+
);
152+
153+
expect(result.imports!['something'].url).toEqual('ipfs://Qmsomething');
154+
155+
expect(jest.mocked(fakeRuntime.putDeploy).mock.calls[0][0].status).toEqual('partial');
156+
157+
jest.mocked(fakeRuntime.isCancelled).mockReturnValue(false);
158+
});
159+
160+
it('works with complete deployment', async () => {
107161
await registry.publish(['hello:1.0.0'], '1234-main', 'https://something.com', '');
108162

109163
jest.mocked(fakeRuntime.readDeploy).mockResolvedValue({

packages/builder/src/steps/provision.ts

+4
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,10 @@ export default {
163163

164164
debug('start build');
165165
const builtState = await build(importRuntime, def, prevState, initialCtx);
166+
if (importRuntime.isCancelled()) {
167+
partialDeploy = true;
168+
}
169+
166170
debug('finish build. is partial:', partialDeploy);
167171

168172
const newMiscUrl = await importRuntime.recordMisc();

0 commit comments

Comments
 (0)