From 6defef8df818edbbff82d129e06afdacab3f9dcd Mon Sep 17 00:00:00 2001 From: nolash Date: Mon, 16 Nov 2020 10:49:58 +0100 Subject: [PATCH] Add test file --- js/test.ts | 25 +++++++++++++++++++++++++ python/eth_accounts_index/__init__.py | 2 +- python/eth_accounts_index/registry.py | 6 +++--- 3 files changed, 29 insertions(+), 4 deletions(-) create mode 100644 js/test.ts diff --git a/js/test.ts b/js/test.ts new file mode 100644 index 0000000..cdd82b7 --- /dev/null +++ b/js/test.ts @@ -0,0 +1,25 @@ +import { AccountRegistry } from './src/registry'; + +const fs = require('fs'); + +const Web3 = require('web3'); + +const w3 = new Web3('http://localhost:8545'); + +const d = fs.readFileSync('../solidity/registry.abi.json'); +const abi = JSON.parse(d); + +const address = process.argv[2]; + +const r = new AccountRegistry(w3, abi, address); + +async function main() { + console.log(await r.count()); + + console.log(await r.have('0xe3C4db5947409Aff0FF8D643047EA41515cA4B8e')); + console.log(await r.have('0x34C85E47f45b0bea09F37c83e2fb02ECBC3a395d')); + + console.log(await r.last(3)); +} + +main(); diff --git a/python/eth_accounts_index/__init__.py b/python/eth_accounts_index/__init__.py index f9691f6..bb7364b 100644 --- a/python/eth_accounts_index/__init__.py +++ b/python/eth_accounts_index/__init__.py @@ -1 +1 @@ -from .registry import Registry +from .registry import AccountRegistry diff --git a/python/eth_accounts_index/registry.py b/python/eth_accounts_index/registry.py index 0248771..fd0ca3e 100644 --- a/python/eth_accounts_index/registry.py +++ b/python/eth_accounts_index/registry.py @@ -9,13 +9,13 @@ class AccountRegistry: abi = None def __init__(self, w3, address, signer_address=None): - if Registry.abi == None: + if AccountRegistry.abi == None: moddir = os.path.dirname(__file__) datadir = os.path.join(moddir, 'data') f = open(os.path.join(datadir, 'registry.abi.json'), 'r') - Registry.abi = json.load(f) + AccountRegistry.abi = json.load(f) f.close() - self.contract = w3.eth.contract(abi=Registry.abi, address=address) + self.contract = w3.eth.contract(abi=AccountRegistry.abi, address=address) self.w3 = w3 if signer_address != None: self.signer_address = signer_address