This repository has been archived by the owner on Oct 6, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #281 from oasislabs/armani/ws
client: Fix workspace deploys
- Loading branch information
Showing
4 changed files
with
116 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import { ServiceDefinition } from '../../src/workspace'; | ||
|
||
describe('ServiceDefinition', () => { | ||
describe('injectBytecode', () => { | ||
const bytecode = new Uint8Array([1, 2, 3]); | ||
const idl = { | ||
constructor: { | ||
inputs: [{ type: 'string' }], | ||
}, | ||
}; | ||
const serviceDef = new ServiceDefinition(bytecode, idl); | ||
|
||
it('injects bytecode into the deploy options', async () => { | ||
const deployOptions = { gasLimit: '0x00' }; | ||
const args = ['hello', deployOptions]; | ||
|
||
// @ts-ignore | ||
serviceDef.injectBytecode(args); | ||
|
||
const expectedArgs = [ | ||
'hello', | ||
{ | ||
...deployOptions, | ||
bytecode, | ||
}, | ||
]; | ||
|
||
// Bytecode should be properly injected. | ||
expect(args).toEqual(expectedArgs); | ||
// Original options should not have been mutated. | ||
expect(deployOptions).toEqual({ gasLimit: '0x00' }); | ||
}); | ||
|
||
it('creates deploy options when none exist', async () => { | ||
const args = ['hello']; | ||
|
||
// @ts-ignore | ||
serviceDef.injectBytecode(args); | ||
|
||
const expectedArgs = [ | ||
'hello', | ||
{ | ||
bytecode, | ||
}, | ||
]; | ||
|
||
expect(args).toEqual(expectedArgs); | ||
}); | ||
|
||
it('errors if bytecode is provided', async () => { | ||
const args = [ | ||
'hello', | ||
{ | ||
bytecode: new Uint8Array([1, 2, 3]), | ||
}, | ||
]; | ||
|
||
try { | ||
// @ts-ignore | ||
serviceDef.injectBytecode(args); | ||
expect(true).toBe(false); | ||
} catch (e) { | ||
expect(e.message).toEqual( | ||
'Bytecode should not be provided when deploying a workspace service' | ||
); | ||
} | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters