nwaku/tests/v2/test_utils.nim

22 lines
602 B
Nim
Raw Normal View History

Test for the Rln relay/membership management contract deployment (#312) * enhancement/cleanup-warnings (#290) Accounting: Move flag to config and add basic test for accounting state (#284) * Accounting: Add config flag (default to false) Also fix bug where query function is called twice when flag is set. * Accounting: test state update after store req Refactor: waku_types separation of concern (trial with waku_swap) (#282) * waku_types refactor: Accounting types to waku_swap * waku_types refactor: Separate waku_swap_types file * Fix import path for waku_swap adds the test file for waku rln relay WIP: adds some initial code commented out the rln-relay test code refactor/db-message-store-split (#280) * fixes * fic * fix * fix * fix * fixed * fix * fixes * fixes, using sqlite lib fully * fix * Update sqlite.nim Waku v2 JSON-RPC REST API: Store protocol proof of concept (#263) * Waku V2 history query POC * Fix folder structure * Improve test clarity * Improve imports, returns and some naming * Changed naming conventions. Refactor & improve. Co-authored-by: Oskar Thorén <ot@oskarthoren.com> Refactor types store (#291) * Refactor: Move waku_store into its own folder * Refactor: Move waku store types to new home (WIP) * Refactor: Fix errors and recursive imports * Fix rebase errors * Refactor: More rebase import fixes Accounting credit receiving node (#292) * Accounting WIP: Swap access through Store * Fix order bug and comment scenario + typo * WIP * Accounting: Account for receiving store node - Turn accountFor function into credit and debit - Misc formatting * Accounting: Fix bugs related to mount and test * Accounting: Simplify query signature We already have a ref to wakuSwap through wakuStore now. * Resolve rebase issues enhancement/remove-flood (#295) * removes flood * rm Co-authored-by: Oskar Thorén <ot@oskarthoren.com> Updated submodules (#303) add Jenkinsfile and some Makefile targets for CI (#302) Signed-off-by: Jakub Sokołowski <jakub@status.im> Co-authored-by: Oskar Thorén <ot@oskarthoren.com> Accounting: End to end with Cheque PoC (#304) Added some basic debug and relay json-rpc calls (#305) Uncomment and call empty rln test adds the membership contract to the test file adds a test utils for contract deployment increases the gas limit for group management contract * removes some files * WIP: adds the interface of membership contract * uncomments the interface of getNumber contract * adds tests for interaction with the membership contract * send is replaced with call * replaces call with send * enhancement/cleanup-warnings (#290) Accounting: Move flag to config and add basic test for accounting state (#284) * Accounting: Add config flag (default to false) Also fix bug where query function is called twice when flag is set. * Accounting: test state update after store req Refactor: waku_types separation of concern (trial with waku_swap) (#282) * waku_types refactor: Accounting types to waku_swap * waku_types refactor: Separate waku_swap_types file * Fix import path for waku_swap adds the test file for waku rln relay WIP: adds some initial code commented out the rln-relay test code refactor/db-message-store-split (#280) * fixes * fic * fix * fix * fix * fixed * fix * fixes * fixes, using sqlite lib fully * fix * Update sqlite.nim Waku v2 JSON-RPC REST API: Store protocol proof of concept (#263) * Waku V2 history query POC * Fix folder structure * Improve test clarity * Improve imports, returns and some naming * Changed naming conventions. Refactor & improve. Co-authored-by: Oskar Thorén <ot@oskarthoren.com> Refactor types store (#291) * Refactor: Move waku_store into its own folder * Refactor: Move waku store types to new home (WIP) * Refactor: Fix errors and recursive imports * Fix rebase errors * Refactor: More rebase import fixes Accounting credit receiving node (#292) * Accounting WIP: Swap access through Store * Fix order bug and comment scenario + typo * WIP * Accounting: Account for receiving store node - Turn accountFor function into credit and debit - Misc formatting * Accounting: Fix bugs related to mount and test * Accounting: Simplify query signature We already have a ref to wakuSwap through wakuStore now. * Resolve rebase issues enhancement/remove-flood (#295) * removes flood * rm Co-authored-by: Oskar Thorén <ot@oskarthoren.com> Updated submodules (#303) add Jenkinsfile and some Makefile targets for CI (#302) Signed-off-by: Jakub Sokołowski <jakub@status.im> Co-authored-by: Oskar Thorén <ot@oskarthoren.com> Accounting: End to end with Cheque PoC (#304) Added some basic debug and relay json-rpc calls (#305) Uncomment and call empty rln test adds the membership contract to the test file adds a test utils for contract deployment increases the gas limit for group management contract * removes some files * WIP: adds the interface of membership contract * uncomments the interface of getNumber contract * adds tests for interaction with the membership contract * send is replaced with call * replaces call with send * adds a todo * removes empty lines * adds some comments * adds a todo * adds the solidity code of the NumberContract * fixes a bug: replaces call with send * removes store test comments * removes excess spaces
2021-01-07 20:34:24 +00:00
import web3, chronos, options, stint
proc deployContract*(web3: Web3, code: string, gasPrice = 0): Future[ReceiptObject] {.async.} =
let provider = web3.provider
let accounts = await provider.eth_accounts()
var code = code
if code[1] notin {'x', 'X'}:
code = "0x" & code
var tr: EthSend
tr.source = web3.defaultAccount
tr.data = code
tr.gas = Quantity(3000000000000).some
if gasPrice != 0:
tr.gasPrice = some(gasPrice)
let r = await web3.send(tr)
return await web3.getMinedTransactionReceipt(r)
proc ethToWei*(eth: UInt256): UInt256 =
eth * 1000000000000000000.u256