-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: contract trait voting verifier (#276)
* refactor: base voting verifier tests template * refactor: finish voting verifier tests migration * fix: handle lint issue * refactor: change config name to fixture * refactor: handle TestFixture name typo
- Loading branch information
Showing
4 changed files
with
402 additions
and
320 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
use crate::{source_chain, POLL_BLOCK_EXPIRY}; | ||
use axelar_wasm_std::{nonempty, Threshold}; | ||
use cosmwasm_std::Addr; | ||
use cw_multi_test::{App, ContractWrapper, Executor}; | ||
use integration_tests::contract::Contract; | ||
use voting_verifier::{ | ||
contract::*, | ||
msg::{ExecuteMsg, InstantiateMsg, QueryMsg}, | ||
}; | ||
|
||
pub struct VotingVerifierContract { | ||
pub contract_addr: Addr, | ||
} | ||
|
||
impl VotingVerifierContract { | ||
pub fn instantiate_contract( | ||
app: &mut App, | ||
service_registry_address: nonempty::String, | ||
rewards_address: String, | ||
) -> Self { | ||
let code = ContractWrapper::new(execute, instantiate, query); | ||
let code_id = app.store_code(Box::new(code)); | ||
|
||
let contract_addr = app | ||
.instantiate_contract( | ||
code_id, | ||
Addr::unchecked("sender"), | ||
&InstantiateMsg { | ||
service_registry_address, | ||
service_name: "service_name".parse().unwrap(), | ||
voting_threshold: Threshold::try_from((2u64, 3u64)) | ||
.unwrap() | ||
.try_into() | ||
.unwrap(), | ||
block_expiry: POLL_BLOCK_EXPIRY, | ||
confirmation_height: 100, | ||
source_gateway_address: "gateway_address".parse().unwrap(), | ||
source_chain: source_chain(), | ||
rewards_address, | ||
}, | ||
&[], | ||
"voting-verifier", | ||
None, | ||
) | ||
.unwrap(); | ||
|
||
VotingVerifierContract { contract_addr } | ||
} | ||
} | ||
|
||
impl Contract for VotingVerifierContract { | ||
type QMsg = QueryMsg; | ||
type ExMsg = ExecuteMsg; | ||
|
||
fn contract_address(&self) -> Addr { | ||
self.contract_addr.clone() | ||
} | ||
} | ||
|
||
pub fn are_contract_err_strings_equal( | ||
actual: impl Into<axelar_wasm_std::ContractError>, | ||
expected: impl Into<axelar_wasm_std::ContractError>, | ||
) { | ||
assert_eq!(actual.into().to_string(), expected.into().to_string()); | ||
} |
Oops, something went wrong.