From 7c6c7dbe3aabf7ca364eee42d7c660604e7682b4 Mon Sep 17 00:00:00 2001 From: andri lim Date: Sat, 2 Feb 2019 16:17:57 +0700 Subject: [PATCH] 'accountExist' to 'accountExists' --- nimbus/db/state_db.nim | 4 ++-- tests/test_state_db.nim | 20 ++++++++++---------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/nimbus/db/state_db.nim b/nimbus/db/state_db.nim index cb4a03aea..78bfeea9c 100644 --- a/nimbus/db/state_db.nim +++ b/nimbus/db/state_db.nim @@ -178,7 +178,7 @@ proc dumpAccount*(db: AccountStateDB, addressS: string): string = let address = addressS.parseAddress return fmt"{addressS}: Storage: {db.getStorage(address, 0.u256)}; getAccount: {db.getAccount address}" -proc accountExist*(db: AccountStateDB, address: EthAddress): bool = +proc accountExists*(db: AccountStateDB, address: EthAddress): bool = db.trie.get(createRangeFromAddress address).len > 0 proc isDeadAccount*(db: AccountStateDB, address: EthAddress): bool = @@ -200,5 +200,5 @@ proc getStorage*(db: ReadOnlyStateDB, address: EthAddress, slot: UInt256): (UInt proc getNonce*(db: ReadOnlyStateDB, address: EthAddress): AccountNonce {.borrow.} proc getCode*(db: ReadOnlyStateDB, address: EthAddress): ByteRange {.borrow.} proc hasCodeOrNonce*(db: ReadOnlyStateDB, address: EthAddress): bool {.borrow.} -proc accountExist*(db: ReadOnlyStateDB, address: EthAddress): bool {.borrow.} +proc accountExists*(db: ReadOnlyStateDB, address: EthAddress): bool {.borrow.} proc isDeadAccount*(db: ReadOnlyStateDB, address: EthAddress): bool {.borrow.} diff --git a/tests/test_state_db.nim b/tests/test_state_db.nim index ff0e81681..c4a7c4428 100644 --- a/tests/test_state_db.nim +++ b/tests/test_state_db.nim @@ -15,31 +15,31 @@ suite "Account State DB": trie = initHexaryTrie(memDB) stateDB = newAccountStateDB(memDB, trie.rootHash, true) address: EthAddress - + hexToByteArray("0x0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", address) - - test "accountExist and isDeadAccount": - check stateDB.accountExist(address) == false + + test "accountExists and isDeadAccount": + check stateDB.accountExists(address) == false check stateDB.isDeadAccount(address) == true - + var acc = stateDB.getAccount(address) acc.balance = 1000.u256 stateDB.setAccount(address, acc) - - check stateDB.accountExist(address) == true + + check stateDB.accountExists(address) == true check stateDB.isDeadAccount(address) == false acc.balance = 0.u256 acc.nonce = 1 stateDB.setAccount(address, acc) check stateDB.isDeadAccount(address) == false - + var code = hexToSeqByte("0x0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6") stateDB.setCode(address, code.toRange) stateDB.setNonce(address, 0) check stateDB.isDeadAccount(address) == false - + code = @[] stateDB.setCode(address, code.toRange) check stateDB.isDeadAccount(address) == true - check stateDB.accountExist(address) == true + check stateDB.accountExists(address) == true