-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
75b8adb
commit f503e0a
Showing
29 changed files
with
1,049 additions
and
120 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
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
7 changes: 3 additions & 4 deletions
7
src/tests/e2e/dpos-tests.ts → src/tests/e2e/contracts/dpos-tests.ts
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
16 changes: 8 additions & 8 deletions
16
src/tests/e2e/client-evm-event-tests-2.ts → ...tests/e2e/evm/client-evm-event-tests-2.ts
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
14 changes: 7 additions & 7 deletions
14
src/tests/e2e/client-evm-event-tests.ts → src/tests/e2e/evm/client-evm-event-tests.ts
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
10 changes: 5 additions & 5 deletions
10
src/tests/e2e/client-evm-tests.ts → src/tests/e2e/evm/client-evm-tests.ts
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
151 changes: 151 additions & 0 deletions
151
src/tests/e2e/loom-provider-2/loom-provider-eth-filters.ts
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,151 @@ | ||
import test from 'tape' | ||
|
||
import { execAndWaitForMillisecondsAsync, getTestUrls } from '../../helpers' | ||
import { deployContract2 } from '../../evm-helpers' | ||
import { LoomProvider2 } from '../../../loom-provider-2' | ||
|
||
/** | ||
* Requires the SimpleStore solidity contract deployed on a loomchain. | ||
* go-loom/examples/plugins/evmexample/contract/SimpleStore.sol | ||
* | ||
* pragma solidity ^0.4.22; | ||
* | ||
* contract SimpleStore { | ||
* uint value; | ||
* | ||
* constructor() { | ||
* value = 10; | ||
* } | ||
* | ||
* event NewValueSet(uint _value); | ||
* | ||
* function set(uint _value) public { | ||
* value = _value; | ||
* emit NewValueSet(value); | ||
* } | ||
* | ||
* function get() public view returns (uint) { | ||
* return value; | ||
* } | ||
* } | ||
* | ||
*/ | ||
|
||
const contractData = | ||
'0x608060405234801561001057600080fd5b50600a600081905550610114806100286000396000f3006080604052600436106049576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806360fe47b114604e5780636d4ce63c14606c575b600080fd5b606a600480360381019080803590602001909291905050506094565b005b348015607757600080fd5b50607e60df565b6040518082815260200191505060405180910390f35b806000819055507f2afa03c814297ffc234ff967b6f0863d3c358be243103f20217c8d3a4d39f9c060005434604051808381526020018281526020019250505060405180910390a150565b600080549050905600a165627a7a72305820deed812a797567167162d0af3ae5f0528c39bea0620e32b28e243628cd655dc40029' | ||
|
||
test('LoomProvider + Filters', async t => { | ||
let loomProvider | ||
|
||
try { | ||
const { wsEth } = getTestUrls() | ||
loomProvider = new LoomProvider2(wsEth) | ||
|
||
await deployContract2(loomProvider, contractData) | ||
|
||
// Transaction receipt in order to obtain the topic of the event NewValueSet | ||
const ethNewFilterResult = await execAndWaitForMillisecondsAsync( | ||
loomProvider.sendAsync({ | ||
id: 10, | ||
method: 'eth_newFilter', | ||
params: [{ toBlock: 'latest' }] | ||
}) | ||
) | ||
|
||
t.assert(/0x.+/.test(ethNewFilterResult.result), 'New id should be created for new filter') | ||
|
||
const ethNewBlockFilter = await execAndWaitForMillisecondsAsync( | ||
loomProvider.sendAsync({ | ||
id: 11, | ||
method: 'eth_newBlockFilter' | ||
}) | ||
) | ||
|
||
t.assert( | ||
/0x.+/.test(ethNewBlockFilter.result), | ||
'New id should be created for new block filter' | ||
) | ||
|
||
const ethGetFilterChanges = await execAndWaitForMillisecondsAsync( | ||
loomProvider.sendAsync({ | ||
id: 12, | ||
method: 'eth_getFilterChanges', | ||
params: [ethNewBlockFilter.result] | ||
}) | ||
) | ||
|
||
t.assert( | ||
ethGetFilterChanges.result.length > 0, | ||
'Get filter changes should return array with new blocks' | ||
) | ||
|
||
const ethUninstallFilterResult = await execAndWaitForMillisecondsAsync( | ||
loomProvider.sendAsync({ | ||
id: 13, | ||
method: 'eth_uninstallFilter', | ||
params: [ethNewBlockFilter.result] | ||
}) | ||
) | ||
|
||
t.deepEqual(ethUninstallFilterResult.result, true, 'Should uninstall filter and return true') | ||
} catch (err) { | ||
t.error(err) | ||
} | ||
|
||
if (loomProvider) { | ||
loomProvider.disconnect() | ||
} | ||
|
||
t.end() | ||
}) | ||
|
||
test('LoomProvider + Filters 2', async t => { | ||
let loomProvider | ||
|
||
try { | ||
const { wsEth } = getTestUrls() | ||
loomProvider = new LoomProvider2(wsEth) | ||
|
||
await deployContract2(loomProvider, contractData) | ||
|
||
const ethNewBlockFilter = await execAndWaitForMillisecondsAsync( | ||
loomProvider.sendAsync({ | ||
id: 11, | ||
method: 'eth_newBlockFilter' | ||
}) | ||
) | ||
|
||
t.assert( | ||
/0x.+/.test(ethNewBlockFilter.result), | ||
'New id should be created for new block filter' | ||
) | ||
|
||
const ethGetFilterChanges = await execAndWaitForMillisecondsAsync( | ||
loomProvider.sendAsync({ | ||
id: 12, | ||
method: 'eth_getFilterChanges', | ||
params: [ethNewBlockFilter.result] | ||
}) | ||
) | ||
|
||
t.assert(ethGetFilterChanges.result.length > 0, 'Should return filter changes') | ||
|
||
const ethGetBlockByHash = await execAndWaitForMillisecondsAsync( | ||
loomProvider.sendAsync({ | ||
id: 13, | ||
method: 'eth_getBlockByHash', | ||
params: [ethGetFilterChanges.result[0], true] | ||
}) | ||
) | ||
|
||
t.assert(ethGetBlockByHash.result, 'Should return the block requested by hash') | ||
} catch (err) { | ||
t.error(err) | ||
} | ||
|
||
if (loomProvider) { | ||
loomProvider.disconnect() | ||
} | ||
|
||
t.end() | ||
}) |
Oops, something went wrong.