Skip to content

Commit

Permalink
feat: making tests compile
Browse files Browse the repository at this point in the history
  • Loading branch information
beqaabu committed Jul 30, 2024
1 parent 92280bf commit 154bd1f
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 36 deletions.
2 changes: 1 addition & 1 deletion pallets/creditcoin/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::{
non_paying_error, EVMAddress, PublicToAddress,
},
mock::{RuntimeOrigin as Origin, *},
ocw::tasks::collect_coins::DeployedContract,
ocw::tasks::verify_transfer::DeployedContract,
types::{DoubleMapExt, OwnershipProof},
AddressId, AskOrder, AskOrderId, BidOrder, BidOrderId, Blockchain, DealOrder, DealOrderId,
DealOrders, Duration, ExternalAddress, ExternalAmount, Guid, Id, LegacySighash, LoanTerms,
Expand Down
47 changes: 24 additions & 23 deletions pallets/creditcoin/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,8 @@ impl<AccountId, BlockNum, Hash, Moment>
pub(crate) mod test {
use crate::{
helpers::extensions::HexToAddress, loan_terms::InvalidTermLengthError, mock,

Check warning on line 569 in pallets/creditcoin/src/types.rs

View workflow job for this annotation

GitHub Actions / unit-test-creditcoin

unused import: `helpers::extensions::HexToAddress`
ocw::tasks::collect_coins::tests::TX_HASH, tests::TestInfo, *,
// ocw::tasks::collect_coins::tests::TX_HASH,
tests::TestInfo, *,
};
use frame_support::BoundedVec;
use parity_scale_codec::{Decode, Encode};
Expand Down Expand Up @@ -675,23 +676,23 @@ pub(crate) mod test {
test_info.create_funding_transfer(&deal_order_id)
}

fn create_collected_coins() -> CollectedCoinsStruct<Hash, Balance> {
CollectedCoinsStruct {
to: AddressId::new::<mock::Test>(&Blockchain::Rinkeby, b"tester"),
amount: 1000,
tx_id: TX_HASH.hex_to_address(),
contract_type: types::ContractType::GCRE,
}
}

fn create_unverified_collected_coins() -> UnverifiedCollectedCoins {
UnverifiedCollectedCoins {
to: b"baba".to_vec().try_into().unwrap(),
tx_id: TX_HASH.hex_to_address(),
contract: Default::default(),
contract_type: types::ContractType::GCRE,
}
}
// fn create_collected_coins() -> CollectedCoinsStruct<Hash, Balance> {
// CollectedCoinsStruct {
// to: AddressId::new::<mock::Test>(&Blockchain::Rinkeby, b"tester"),
// amount: 1000,
// tx_id: TX_HASH.hex_to_address(),
// contract_type: types::ContractType::GCRE,
// }
// }

// fn create_unverified_collected_coins() -> UnverifiedCollectedCoins {
// UnverifiedCollectedCoins {
// to: b"baba".to_vec().try_into().unwrap(),
// tx_id: TX_HASH.hex_to_address(),
// contract: Default::default(),
// contract_type: types::ContractType::GCRE,
// }
// }

pub(crate) fn create_unverified_transfer(
) -> UnverifiedTransfer<AccountId, BlockNum, Hash, Moment> {
Expand Down Expand Up @@ -721,9 +722,9 @@ pub(crate) mod test {
blockchain: Blockchain : Blockchain::Bitcoin,
transfer_kind: TransferKind : TransferKind::Native,
address: Address<AccountId> : create_address(),
collected_coins: CollectedCoinsStruct<Hash, Balance> : create_collected_coins(),
//collected_coins: CollectedCoinsStruct<Hash, Balance> : create_collected_coins(),
transfer: Transfer<AccountId, BlockNum, Hash, Moment> : create_funding_transfer().1,
unverified_collected_coins: UnverifiedCollectedCoins : create_unverified_collected_coins(),
//unverified_collected_coins: UnverifiedCollectedCoins : create_unverified_collected_coins(),
unverified_transfer: UnverifiedTransfer<AccountId, BlockNum, Hash, Moment> : create_unverified_transfer(),
offer: Offer<AccountId, BlockNum, Hash> : TestInfo::new_defaults().create_offer().1,
ask_order: AskOrder<AccountId, BlockNum, Hash> : TestInfo::new_defaults().create_ask_order().1,
Expand All @@ -736,11 +737,11 @@ pub(crate) mod test {
order_id: OrderId<BlockNum, Hash> : OrderId::Deal(TestInfo::new_defaults().create_deal_order().0),
offer_id: OfferId<BlockNum, Hash> : TestInfo::new_defaults().create_offer().0,
transfer_id: TransferId<Hash> : TransferId::new::<mock::Test>(&Blockchain::Rinkeby, b"0"),
collected_coins_id: CollectedCoinsId<Hash> : CollectedCoinsId::new::<mock::Test>(&Blockchain::Rinkeby, &[0]),
//collected_coins_id: CollectedCoinsId<Hash> : CollectedCoinsId::new::<mock::Test>(&Blockchain::Rinkeby, &[0]),
legacy_sighash: LegacySighash : LegacySighash::default(),
task: Task<AccountId, BlockNum, Hash, Moment> : Task::<AccountId, BlockNum, Hash, Moment>::from(create_unverified_collected_coins()),
//task: Task<AccountId, BlockNum, Hash, Moment> : Task::<AccountId, BlockNum, Hash, Moment>::from(create_unverified_collected_coins()),
task_id: TaskId<Hash> : TaskId::from(create_funding_transfer().0),
task_output: TaskOutput<AccountId, Balance, BlockNum, Hash, Moment> : TaskOutput::<AccountId, Balance, BlockNum, Hash, Moment>::from(
task_output: TaskOutput<AccountId, BlockNum, Hash, Moment> : TaskOutput::<AccountId, BlockNum, Hash, Moment>::from(
create_funding_transfer()
),

Expand Down
24 changes: 12 additions & 12 deletions runtime/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,15 @@ fn must_be_root_to_schedule() {
});
}

#[test]
fn authority_migration_parity_checks() {
use pallet_creditcoin::migrations::v7::{Authorities as AC, SCHEDULER_PREFIX};
use pallet_offchain_task_scheduler::Authorities as AT;

//Pallet prefix
let scheduler_prefix = TaskScheduler::name();
assert_eq!(SCHEDULER_PREFIX, scheduler_prefix);

//Storage Prefix
assert_eq!(AT::<Runtime>::storage_prefix(), AC::<Runtime>::storage_prefix());
}
// #[test]
// fn authority_migration_parity_checks() {
// use pallet_creditcoin::migrations::v7::{Authorities as AC, SCHEDULER_PREFIX};
// use pallet_offchain_task_scheduler::Authorities as AT;
//
// //Pallet prefix
// let scheduler_prefix = TaskScheduler::name();
// assert_eq!(SCHEDULER_PREFIX, scheduler_prefix);
//
// //Storage Prefix
// assert_eq!(AT::<Runtime>::storage_prefix(), AC::<Runtime>::storage_prefix());
// }

0 comments on commit 154bd1f

Please sign in to comment.