Skip to content

Commit

Permalink
add test for reading collection
Browse files Browse the repository at this point in the history
  • Loading branch information
brunopgalvao committed Apr 30, 2024
1 parent 5568120 commit 63a9452
Showing 1 changed file with 28 additions and 3 deletions.
31 changes: 28 additions & 3 deletions runtime/devnet/src/extensions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -531,10 +531,35 @@ mod tests {
}

// check that the nft collection was created
assert_eq!(Nfts::collection_owner(0), Some(addr.into()));
assert_eq!(Nfts::collection_owner(0), Some(addr.clone().into()));

// // check for revert
assert!(!result.result.unwrap().did_revert(), "Contract reverted!");
// test reading the collection
let function = function_selector("read_collection");

let params = [function, 0.encode()].concat();

let result = Contracts::bare_call(
ALICE,
addr.clone(),
0,
Weight::from_parts(100_000_000_000, 3 * 1024 * 1024),
None,
params,
DEBUG_OUTPUT,
pallet_contracts::CollectEvents::Skip,
pallet_contracts::Determinism::Enforced,
);

if DEBUG_OUTPUT == pallet_contracts::DebugInfo::UnsafeDebug {
log::debug!(
"Contract debug buffer - {:?}",
String::from_utf8(result.debug_message.clone())
);
log::debug!("result: {:?}", result);
}

// assert that the collection was read successfully
assert_eq!(result.result.clone().unwrap().data, vec![1, 1]);
});
}

Expand Down

0 comments on commit 63a9452

Please sign in to comment.