Skip to content

Commit

Permalink
test/state/prefix_iter: avoid generating empty kvs list
Browse files Browse the repository at this point in the history
  • Loading branch information
tzemanovic committed Aug 9, 2024
1 parent 682d7ff commit 2bec2c3
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions crates/state/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -693,6 +693,7 @@ mod tests {
use merkle_tree::NO_DIFF_KEY_PREFIX;
use namada_core::address::InternalAddress;
use namada_core::borsh::{BorshDeserialize, BorshSerializeExt};
use namada_core::keccak::KeccakHash;
use namada_core::parameters::{EpochDuration, Parameters};
use namada_core::storage::DbKeySeg;
use namada_core::time::{self, DateTimeUtc, Duration};
Expand Down Expand Up @@ -1279,15 +1280,22 @@ mod tests {
)
.prop_map(|kvs| {
kvs.into_iter()
.filter_map(|(key, val)| {
.map(|(mut key, val)| {
if let DbKeySeg::AddressSeg(Address::Internal(
InternalAddress::EthBridgePool,
)) = key.segments[0]
{
None
} else {
Some((key, Level::Storage(val)))
// This is needed to be able to write this key to DB -
// the merkle tree's `BridgePoolTree::parse_key`
// requires a `KeccakHash` on the 2nd segment
key.segments.insert(
1,
DbKeySeg::StringSeg(
KeccakHash::default().to_string(),
),
);
}
(key, Level::Storage(val))
})
.collect::<Vec<_>>()
});
Expand Down

0 comments on commit 2bec2c3

Please sign in to comment.