Skip to content

Commit

Permalink
fix NewCollection event
Browse files Browse the repository at this point in the history
  • Loading branch information
asiniscalchi committed Oct 27, 2023
1 parent e3cee7e commit cdd30e8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
5 changes: 2 additions & 3 deletions evolution-chain/precompile/laos-evolution/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,10 @@ where
match LaosEvolution::create_collection(owner.into()) {
Ok(collection_id) => {
LogsBuilder::new(context.address)
.log3(
.log2(
SELECTOR_LOG_NEW_COLLECTION,
H256::from_low_u64_be(collection_id.to_be()),
owner,
Vec::new(),
EvmDataWriter::new().write(collection_id).build(),
)
.record(handle)?;

Expand Down
20 changes: 16 additions & 4 deletions evolution-chain/precompile/laos-evolution/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
//TODO: remove this and fix clippy issues
#![allow(clippy::redundant_closure_call)]

use core::str::FromStr;

use super::*;
use frame_support::assert_ok;
use precompile_utils::{
Expand Down Expand Up @@ -78,7 +80,7 @@ fn create_collection_should_return_collection_id() {

#[test]
fn create_collection_should_generate_log() {
impl_precompile_mock_simple!(Mock, Ok(0), None, Ok(0.into()), None);
impl_precompile_mock_simple!(Mock, Ok(123), None, Ok(0.into()), None);

let input = EvmDataWriter::new_with_selector(Action::CreateCollection)
.write(Address(H160([1u8; 20])))
Expand All @@ -90,10 +92,20 @@ fn create_collection_should_generate_log() {
let logs = handle.logs;
assert_eq!(logs.len(), 1);
assert_eq!(logs[0].address, H160::zero());
assert_eq!(logs[0].topics.len(), 3);
assert_eq!(logs[0].topics.len(), 2);
assert_eq!(logs[0].topics[0], SELECTOR_LOG_NEW_COLLECTION.into());
assert_eq!(logs[0].topics[1], H256::from_low_u64_be(0));
assert_eq!(logs[0].data, Vec::<u8>::new());
assert_eq!(
logs[0].topics[1],
H256::from_str("0x0000000000000000000000000101010101010101010101010101010101010101")
.unwrap()
);
assert_eq!(
logs[0].data,
vec![
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 123
]
);
}

#[test]
Expand Down

0 comments on commit cdd30e8

Please sign in to comment.