From 23936f5dfa4c0187bebcda02ffeb743bdeb1b08b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Powaga?= Date: Wed, 16 Oct 2019 15:20:43 +0100 Subject: [PATCH] =?UTF-8?q?feat(state=20channels):=20make=20state=20channe?= =?UTF-8?q?ls=20compatible=20with=20node=20v5.0.0=E2=80=A6=20(#688)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat(Lima): Create Lima branch * feat(Compiler): Compiler 4.0.0 compatibility (#632) * feat(newCompiler): Increase compiler version. Add `backend` option to compiler API * fix(TX): Add fate vm version * feat(Contract): Make Contract works with node 5.0.0 rc1 (lima hard-fork) and compiler 4.0.0 rc2 * chore(test): Debug channel test * fix(channel): fix contract in channel test * chore(test): Remove logs * feat(ACI): Add `payable` to contract call * feat(ACI): Add test for payable * fix(Linter): Fix linter error * feat(Compiler): Point to compiler 3.2.0. Improve `payble` to support old compiler * feat(Compiler): disable payable test * feat(Lima): Point compiler to 4.0.0. Enable tests for `payable` * feat(Lima): Make contact for channel test payable * chore(test): Enable tests * feat(Contract/ACI): Add ability to use contract with external deps(`include "someLib"`) (#653) * docs(Contract): Adjust contract docs (#658) * Release 4.7.0-next.1 (#660) * chore(release): Generate CHANGELOG. Bump version * chore(test): Test backward compatibility * chore(test): revert * feat(SCHEMA): Add fate constants * chore(release): bump version to 5.0.0-next.1 * feat(Lima): add check for compiler <-> consensus protocol version check * feat(Lima): add check for abi/vm <-> backend(FATE/AEVM) (#680) * feat(Lima): add check for abi/vm <-> backend(FATE/AEVM) * feat(Lima): add check for abi/vm <-> backend(FATE/AEVM) * feat(Contract): Add fate tests * feat(Contract): enable all tests * feat(Node): Add check in dry-run endpoint(node cross compatibility) * feat(Contract): enable all tests * feat(Contract): enable all tests * feat(Contract): fix docker file run command * feat(Swagger): Resolve refs * feat(tests): Skip Channel and AENS * feat(Node): Change compatibility range from 4.x.x to 5.x.x * feat(Node): Change compatibility range from 4.x.x to 6.0.0 * fix(Oracle): fix abi field resolving * chrome(build): Regenerate lock * feat(state channels): make state channels compatible with node v5.0.0-rc.2 * feat(Compiler): make FATE by default (#693) * feat(Contract): Use FATE by default * Fix lint error * feat(AENS): Lima compatibility (#687) * Aens lima compatibility * Make aens cross compatible with pre-lima releases * Remove .only * Fix native build of claim tx test * feat(GA): Make GA compatible with Lima. Add cross compiler compatibility * fix(Test): Fix test for cross compatibility. Add test for AEVM * fix(AE): Add pointers verification for spend by name. Improve AENS cross node tests * build(Node): Point node to 5.0.0-rc3 * Change node version to v5.0.0-rc.3 * Fix test * Fix channel contracts tests --- CHANGELOG.md | 2 +- docs/api/ae/contract.md | 3 +++ es/channel/handlers.js | 2 ++ package-lock.json | 2 +- test/integration/channel.js | 25 +++++++++++++------------ 5 files changed, 20 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bf26f71035..d7567eadeb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1080,4 +1080,4 @@ fix(AEP exampe): Fix contract in AEPP example ### Bug Fixes -* **Chore** More consistent code examples +* **Chore** More consistent code examples \ No newline at end of file diff --git a/docs/api/ae/contract.md b/docs/api/ae/contract.md index 8292ecb9e7..fd8874c53c 100644 --- a/docs/api/ae/contract.md +++ b/docs/api/ae/contract.md @@ -215,7 +215,10 @@ Compile contract source code | source | `String` | | Contract sourece code | | [options] | `Object` | {} | Transaction options (fee, ttl, gas, amount, deposit) | | [options.filesystem] | `Object` | {} | Contract external namespaces map* @return {Promise} Result object | +<<<<<<< HEAD +======= | [options.backend] | `Object` | 'aevm' | Contract backend version (aevm|fate) | +>>>>>>> develop **Example** ```js diff --git a/es/channel/handlers.js b/es/channel/handlers.js index ee05f6d369..953edfa65c 100644 --- a/es/channel/handlers.js +++ b/es/channel/handlers.js @@ -174,6 +174,8 @@ export async function channelOpen (channel, message, state) { case 'died': changeStatus(channel, 'died') return { handler: channelClosed } + case 'shutdown': + return { handler: channelOpen } } break case 'channels.on_chain_tx': diff --git a/package-lock.json b/package-lock.json index 910d4e1c7e..8c26abed4d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12143,4 +12143,4 @@ } } } -} +} \ No newline at end of file diff --git a/test/integration/channel.js b/test/integration/channel.js index 4fabcad6d5..600fb9c1fb 100644 --- a/test/integration/channel.js +++ b/test/integration/channel.js @@ -29,8 +29,8 @@ const wsUrl = process.env.TEST_WS_URL || 'ws://localhost:3014/channel' plan(BigNumber('1000e18').toString()) const identityContract = ` -payable contract Identity = - payable entrypoint main(x : int): int = x +contract Identity = + entrypoint main(x : int) : int = x ` function waitForChannel (channel) { @@ -73,7 +73,8 @@ describe.skip('Channel', function () { ttl: 10000, host: 'localhost', port: 3001, - lockPeriod: 1 + lockPeriod: 1, + statePassword: 'correct horse battery staple' } before(async function () { @@ -735,24 +736,24 @@ describe.skip('Channel', function () { sign: responderSign }) await Promise.all([waitForChannel(initiatorCh), waitForChannel(responderCh)]) - const code = await initiator.compileContractAPI(identityContract) - const callData = await initiator.contractEncodeCallDataAPI(identityContract, 'init', []) + const code = await initiator.compileContractAPI(identityContract, { backend: 'aevm' }) + const callData = await initiator.contractEncodeCallDataAPI(identityContract, 'init', [], { backend: 'aevm' }) const result = await initiatorCh.createContract({ code, callData, deposit: 1000, - vmVersion: 4, + vmVersion: 6, abiVersion: 1 }, async (tx) => initiator.signTransaction(tx)) result.should.eql({ accepted: true, address: result.address, signedTx: (await initiatorCh.state()).signedTx }) contractAddress = result.address - contractEncodeCall = (method, args) => initiator.contractEncodeCallDataAPI(identityContract, method, args) + contractEncodeCall = (method, args) => initiator.contractEncodeCallDataAPI(identityContract, method, args, { backend: 'aevm' }) }) it('can create a contract and reject', async () => { responderShouldRejectUpdate = true - const code = await initiator.compileContractAPI(identityContract) - const callData = await initiator.contractEncodeCallDataAPI(identityContract, 'init', []) + const code = await initiator.compileContractAPI(identityContract, { backend: 'aevm' }) + const callData = await initiator.contractEncodeCallDataAPI(identityContract, 'init', [], { backend: 'aevm' }) const result = await initiatorCh.createContract({ code, callData, @@ -808,7 +809,7 @@ describe.skip('Channel', function () { it('can call a contract using dry-run', async () => { const result = await initiatorCh.callContractStatic({ - amount: BigNumber('2e18'), + amount: 0, callData: await contractEncodeCall('main', ['42']), contract: contractAddress, abiVersion: 1 @@ -834,7 +835,7 @@ describe.skip('Channel', function () { caller: await initiator.address(), contract: contractAddress, round: callerNonce - }).should.eventually.be.rejectedWith('Rejected: Call not found') + }).should.eventually.be.rejected }) it('can get contract state', async () => { @@ -847,7 +848,7 @@ describe.skip('Channel', function () { id: contractAddress, ownerId: await initiator.address(), referrerIds: [], - vmVersion: 4 + vmVersion: 6 }, contractState: result.contractState })