Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
fish-sammy committed Jan 9, 2025
1 parent 6f3c4e8 commit 896e4dc
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 53 deletions.
63 changes: 29 additions & 34 deletions contracts/voting-verifier/src/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,16 +208,15 @@ mod test {
use axelar_wasm_std::voting::Vote;
use axelar_wasm_std::{nonempty, Threshold, VerificationStatus};
use cosmwasm_std::testing::MockApi;
use cosmwasm_std::{Attribute, Uint128};
use cosmwasm_std::Uint128;
use multisig::key::KeyType;
use multisig::test::common::{build_verifier_set, ecdsa_test_data};
use multisig::verifier_set::VerifierSet;
use router_api::{CrossChainId, Message};
use serde_json::json;

use super::{TxEventConfirmation, VerifierSetConfirmation};
use crate::events::{PollEnded, PollMetadata, PollStarted, QuorumReached, Voted};
use crate::state::Config;
use crate::events::{EmptyEvent, Event};

fn random_32_bytes() -> [u8; 32] {
let mut bytes = [0; 32];
Expand Down Expand Up @@ -401,7 +400,7 @@ mod test {
fn events_should_not_change() {
let api = MockApi::default();

let config = Config {
let event_instantiated: cosmwasm_std::Event = EmptyEvent::Instantiated {
service_name: "serviceName".try_into().unwrap(),
service_registry_contract: api.addr_make("serviceRegistry_contract"),
source_gateway_address: "sourceGatewayAddress".try_into().unwrap(),
Expand All @@ -412,11 +411,10 @@ mod test {
rewards_contract: api.addr_make("rewardsContract"),
msg_id_format: MessageIdFormat::HexTxHashAndEventIndex,
address_format: AddressFormat::Eip55,
};
let event_instantiated =
cosmwasm_std::Event::new("instantiated").add_attributes(<Vec<Attribute>>::from(config));
}
.into();

let event_messages_poll_started: cosmwasm_std::Event = PollStarted::Messages {
let event_messages_poll_started: cosmwasm_std::Event = EmptyEvent::MessagesPollStarted {
messages: vec![
TxEventConfirmation {
tx_id: "txId1".try_into().unwrap(),
Expand All @@ -437,29 +435,27 @@ mod test {
payload_hash: [1; 32],
},
],
metadata: PollMetadata {
poll_id: 1.into(),
source_chain: "sourceChain".try_into().unwrap(),
source_gateway_address: "sourceGatewayAddress".try_into().unwrap(),
confirmation_height: 1,
expires_at: 1,
participants: vec![
api.addr_make("participant1"),
api.addr_make("participant2"),
api.addr_make("participant3"),
],
},
poll_id: 1.into(),
source_chain: "sourceChain".try_into().unwrap(),
source_gateway_address: "sourceGatewayAddress".try_into().unwrap(),
confirmation_height: 1,
expires_at: 1,
participants: vec![
api.addr_make("participant1"),
api.addr_make("participant2"),
api.addr_make("participant3"),
],
}
.into();

let event_verifier_set_poll_started: cosmwasm_std::Event = PollStarted::VerifierSet {
verifier_set: VerifierSetConfirmation {
tx_id: "txId".try_into().unwrap(),
event_index: 1,
message_id: "messageId".try_into().unwrap(),
verifier_set: build_verifier_set(KeyType::Ecdsa, &ecdsa_test_data::signers()),
},
metadata: PollMetadata {
let event_verifier_set_poll_started: cosmwasm_std::Event =
EmptyEvent::VerifierSetPollStarted {
verifier_set: VerifierSetConfirmation {
tx_id: "txId".try_into().unwrap(),
event_index: 1,
message_id: "messageId".try_into().unwrap(),
verifier_set: build_verifier_set(KeyType::Ecdsa, &ecdsa_test_data::signers()),
},
poll_id: 2.into(),
source_chain: "sourceChain".try_into().unwrap(),
source_gateway_address: "sourceGatewayAddress".try_into().unwrap(),
Expand All @@ -470,25 +466,24 @@ mod test {
api.addr_make("participant5"),
api.addr_make("participant6"),
],
},
}
.into();
}
.into();

let event_quorum_reached: cosmwasm_std::Event = QuorumReached {
let event_quorum_reached: cosmwasm_std::Event = Event::QuorumReached {
content: "content".to_string(),
status: VerificationStatus::NotFoundOnSourceChain,
poll_id: 1.into(),
}
.into();

let event_voted: cosmwasm_std::Event = Voted {
let event_voted: cosmwasm_std::Event = EmptyEvent::Voted {
poll_id: 1.into(),
voter: api.addr_make("voter"),
votes: vec![Vote::SucceededOnChain, Vote::FailedOnChain, Vote::NotFound],
}
.into();

let event_poll_ended: cosmwasm_std::Event = PollEnded {
let event_poll_ended: cosmwasm_std::Event = EmptyEvent::PollEnded {
poll_id: 1.into(),
source_chain: "sourceChain".try_into().unwrap(),
results: vec![
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,36 @@
"event_instantiated": {
"attributes": [
{
"key": "service_name",
"value": "serviceName"
"key": "service_registry_contract",
"value": "\"cosmwasm19d2spdjdycg0tfu27n2zrkwvr25yxwykaxvxwkpnf7hqkka93j4sfp809w\""
},
{
"key": "service_registry_contract",
"value": "cosmwasm19d2spdjdycg0tfu27n2zrkwvr25yxwykaxvxwkpnf7hqkka93j4sfp809w"
"key": "service_name",
"value": "\"serviceName\""
},
{
"key": "source_gateway_address",
"value": "sourceGatewayAddress"
"value": "\"sourceGatewayAddress\""
},
{
"key": "voting_threshold",
"value": "[\"2\",\"3\"]"
},
{
"key": "block_expiry",
"value": "10"
"value": "\"10\""
},
{
"key": "confirmation_height",
"value": "1"
},
{
"key": "source_chain",
"value": "sourcechain"
"value": "\"sourcechain\""
},
{
"key": "rewards_contract",
"value": "cosmwasm1wyhnds94w36ar6jlz4aaaz75cmypwmr0rqnc92nm5m79ejy04hnsx25urh"
"value": "\"cosmwasm1wyhnds94w36ar6jlz4aaaz75cmypwmr0rqnc92nm5m79ejy04hnsx25urh\""
},
{
"key": "msg_id_format",
Expand All @@ -56,11 +56,11 @@
},
{
"key": "source_chain",
"value": "sourcechain"
"value": "\"sourcechain\""
},
{
"key": "source_gateway_address",
"value": "sourceGatewayAddress"
"value": "\"sourceGatewayAddress\""
},
{
"key": "confirmation_height",
Expand Down Expand Up @@ -123,11 +123,11 @@
},
{
"key": "source_chain",
"value": "sourcechain"
"value": "\"sourcechain\""
},
{
"key": "source_gateway_address",
"value": "sourceGatewayAddress"
"value": "\"sourceGatewayAddress\""
},
{
"key": "confirmation_height",
Expand All @@ -152,7 +152,7 @@
},
{
"key": "voter",
"value": "cosmwasm12ehr5qctpa78s2r2luz4lqyuzm955nxvj5msmptpatlf3qzj0xds4lvke5"
"value": "\"cosmwasm12ehr5qctpa78s2r2luz4lqyuzm955nxvj5msmptpatlf3qzj0xds4lvke5\""
},
{
"key": "votes",
Expand Down
12 changes: 6 additions & 6 deletions packages/axelar-wasm-std-derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,15 @@ pub fn into_contract_error_derive(input: TokenStream) -> TokenStream {
/// }
/// }
///
/// let actual = Event::from(SomeEvents::SomeEmptyEvent::<Empty, Empty>);
/// let actual: Event = SomeEvents::SomeEmptyEvent::<Empty, Empty>.into();
/// let expected = Event::new("some_empty_event");
/// assert_eq!(actual, expected);
///
/// let actual = Event::from(SomeEvents::SomeOtherEmptyEvent::<Empty, Empty> {});
/// let actual: Event = SomeEvents::SomeOtherEmptyEvent::<Empty, Empty> {}.into();
/// let expected = Event::new("some_other_empty_event");
/// assert_eq!(actual, expected);
///
/// let actual = Event::from(SomeEvents::SomeEvent::<Empty, Empty> {
/// let actual: Event = SomeEvents::SomeEvent::<Empty, Empty> {
/// some_uint: 42,
/// some_string: "some string".to_string(),
/// some_bool: true,
Expand All @@ -82,18 +82,18 @@ pub fn into_contract_error_derive(input: TokenStream) -> TokenStream {
/// some_vec: vec!["a".to_string(), "b".to_string()],
/// some_map: [("a".to_string(), "b".to_string()), ("c".to_string(), "d".to_string()), ("e".to_string(), "f".to_string())].into_iter().collect(),
/// },
/// });
/// }.into();
/// let expected = Event::new("some_event")
/// .add_attribute("some_uint", "42")
/// .add_attribute("some_string", "\"some string\"")
/// .add_attribute("some_bool", "true")
/// .add_attribute("some_object", "{\"some_option\":\"some option\",\"some_other_option\":null,\"some_vec\":[\"a\",\"b\"],\"some_map\":{\"a\":\"b\",\"c\":\"d\",\"e\":\"f\"}}");
/// assert_eq!(actual, expected);
///
/// let actual = Event::from(SomeEvents::SomeGenericsEvent::<String, u64> {
/// let actual: Event = SomeEvents::SomeGenericsEvent::<String, u64> {
/// some_generics: "some generics".to_string(),
/// some_other_generics: 42,
/// });
/// }.into();
/// let expected = Event::new("some_generics_event")
/// .add_attribute("some_generics", "\"some generics\"")
/// .add_attribute("some_other_generics", "42");
Expand Down

0 comments on commit 896e4dc

Please sign in to comment.