Update keccak of address to be a common.Hash instead of a common.Address

This commit is contained in:
Elizabeth Engelman
2019-09-25 16:34:31 -05:00
parent a8a8fe4ac2
commit 66d695d93b
7 changed files with 56 additions and 54 deletions
@@ -62,11 +62,11 @@ func (fetcher GethRpcStorageFetcher) FetchStorageDiffs(out chan<- utils.StorageD
for _, storage := range account.Storage {
logrus.Trace("adding storage diff to out channel")
out <- utils.StorageDiff{
Contract: common.BytesToAddress(account.Key),
BlockHash: stateDiff.BlockHash,
BlockHeight: int(stateDiff.BlockNumber.Int64()),
StorageKey: common.BytesToHash(storage.Key),
StorageValue: common.BytesToHash(storage.Value),
KeccakOfContractAddress: common.BytesToHash(account.Key),
BlockHash: stateDiff.BlockHash,
BlockHeight: int(stateDiff.BlockNumber.Int64()),
StorageKey: common.BytesToHash(storage.Key),
StorageValue: common.BytesToHash(storage.Value),
}
}
}
@@ -101,20 +101,18 @@ var _ = Describe("Geth RPC Storage Fetcher", func() {
height := test_data.BlockNumber
intHeight := int(height.Int64())
expectedStorageDiff := utils.StorageDiff{
//this is not the contract address, but the keccak 256 of the address
Contract: common.BytesToAddress(test_data.ContractLeafKey[:]),
BlockHash: common.HexToHash("0xfa40fbe2d98d98b3363a778d52f2bcd29d6790b9b3f3cab2b167fd12d3550f73"),
BlockHeight: intHeight,
StorageKey: common.BytesToHash(test_data.StorageKey),
StorageValue: common.BytesToHash(test_data.StorageValue),
KeccakOfContractAddress: common.BytesToHash(test_data.ContractLeafKey[:]),
BlockHash: common.HexToHash("0xfa40fbe2d98d98b3363a778d52f2bcd29d6790b9b3f3cab2b167fd12d3550f73"),
BlockHeight: intHeight,
StorageKey: common.BytesToHash(test_data.StorageKey),
StorageValue: common.BytesToHash(test_data.StorageValue),
}
anotherExpectedStorageDiff := utils.StorageDiff{
//this is not the contract address, but the keccak 256 of the address
Contract: common.BytesToAddress(test_data.AnotherContractLeafKey[:]),
BlockHash: common.HexToHash("0xfa40fbe2d98d98b3363a778d52f2bcd29d6790b9b3f3cab2b167fd12d3550f73"),
BlockHeight: intHeight,
StorageKey: common.BytesToHash(test_data.StorageKey),
StorageValue: common.BytesToHash(test_data.StorageValue),
KeccakOfContractAddress: common.BytesToHash(test_data.AnotherContractLeafKey[:]),
BlockHash: common.HexToHash("0xfa40fbe2d98d98b3363a778d52f2bcd29d6790b9b3f3cab2b167fd12d3550f73"),
BlockHeight: intHeight,
StorageKey: common.BytesToHash(test_data.StorageKey),
StorageValue: common.BytesToHash(test_data.StorageValue),
}
Expect(<-storagediffChan).To(Equal(expectedStorageDiff))
Expect(<-storagediffChan).To(Equal(anotherExpectedStorageDiff))