Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix failing make test-wasm in eth-bridge-integration #699

Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions shared/src/ledger/storage/merkle_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,10 @@ pub enum Error {
StoreType(String),
#[error("Non-existence proofs not supported for store type: {0}")]
NonExistenceProof(String),
#[error("Invalid value given to sub-tree storage")]
InvalidValue,
#[error("Expected a bytes value")]
ExpectedBytesValue,
#[error("Expected a bridge pool transfer value")]
ExpectedBridgePoolTransferValue,
#[error("ICS23 commitment proofs do not support multiple leaves")]
Ics23MultiLeaf,
#[error("A Tendermint proof can only be constructed from an ICS23 proof.")]
Expand Down
8 changes: 4 additions & 4 deletions shared/src/ledger/storage/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ impl<'a, H: StorageHasher + Default> SubTreeRead for &'a Smt<H> {
let key: &Key = &keys[0];
let value = match values.remove(0) {
MerkleValue::Bytes(b) => b,
_ => return Err(Error::InvalidValue),
_ => return Err(Error::ExpectedBytesValue),
};
let cp = self.membership_proof(&H::hash(key.to_string()).into())?;
// Replace the values and the leaf op for the verification
Expand Down Expand Up @@ -90,7 +90,7 @@ impl<'a, H: StorageHasher + Default> SubTreeWrite for &'a mut Smt<H> {
) -> Result<Hash, Error> {
let value = match value {
MerkleValue::Bytes(bytes) => H::hash(bytes.as_slice()),
_ => return Err(Error::InvalidValue),
_ => return Err(Error::ExpectedBytesValue),
};
self.update(H::hash(key.to_string()).into(), value.into())
.map(Hash::from)
Expand Down Expand Up @@ -149,7 +149,7 @@ impl<'a, H: StorageHasher + Default> SubTreeWrite for &'a mut Amt<H> {
let key = StringKey::try_from_bytes(key.to_string().as_bytes())?;
let value = match value {
MerkleValue::Bytes(bytes) => TreeBytes::from(bytes),
_ => return Err(Error::InvalidValue),
_ => return Err(Error::ExpectedBytesValue),
};
self.update(key, value)
.map(Into::into)
Expand Down Expand Up @@ -199,7 +199,7 @@ impl<'a> SubTreeWrite for &'a mut BridgePoolTree {
self.insert_key(key)
.map_err(|err| Error::MerkleTree(err.to_string()))
} else {
Err(Error::InvalidValue)
Err(Error::ExpectedBridgePoolTransferValue)
}
}

Expand Down
16 changes: 13 additions & 3 deletions tests/src/vm_host_env/tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,24 @@ impl TestTxEnv {
);
}

/// Fake accounts existence by initializating their VP storage.
/// This is needed for accounts that are being modified by a tx test to be
/// pass account existence check in `tx_write` function.
/// Fake accounts' existence by initializing their VP storage.
/// This is needed for accounts that are being modified by a tx test to
/// pass account existence check in `tx_write` function. Only established
/// addresses ([`Address::Established`]) have their VP storage initialized,
/// as other types of accounts should not have wasm VPs in storage in any
/// case.
pub fn spawn_accounts(
&mut self,
addresses: impl IntoIterator<Item = impl Borrow<Address>>,
) {
for address in addresses {
if matches!(
address.borrow(),
Address::Internal(_) | Address::Implicit(_)
) {
// don't write a VP for internal addresses
continue;
}
let key = Key::validity_predicate(address.borrow());
let vp_code = vec![];
self.storage
Expand Down