'accountExist' to 'accountExists'

This commit is contained in:
andri lim 2019-02-02 16:17:57 +07:00 committed by zah
parent 4cc0ef427c
commit 7c6c7dbe3a
2 changed files with 12 additions and 12 deletions

View File

@ -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.}

View File

@ -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