pallet-atomic-swap: generialized swap action (#6421)

* pallet-atomic-swap: generialized swap action

* Bump spec_version

* Fix weight calculation

* Remove unnecessary type aliases
This commit is contained in:
Wei Tang
2020-06-21 12:34:53 +02:00
committed by GitHub
parent 7653b5592c
commit 039c30f08c
3 changed files with 111 additions and 50 deletions
+6 -4
View File
@@ -21,7 +21,7 @@ impl_outer_origin! {
// For testing the pallet, we construct most of a mock runtime. This means
// first constructing a configuration type (`Test`) which `impl`s each of the
// configuration traits of pallets we want to use.
#[derive(Clone, Eq, PartialEq)]
#[derive(Clone, Eq, Debug, PartialEq)]
pub struct Test;
parameter_types! {
pub const BlockHashCount: u64 = 250;
@@ -71,7 +71,7 @@ parameter_types! {
}
impl Trait for Test {
type Event = ();
type Currency = Balances;
type SwapAction = BalanceSwapAction<Test, Balances>;
type ProofLimit = ProofLimit;
}
type System = frame_system::Module<Test>;
@@ -109,7 +109,7 @@ fn two_party_successful_swap() {
Origin::signed(A),
B,
hashed_proof.clone(),
50,
BalanceSwapAction::new(50),
1000,
).unwrap();
@@ -123,7 +123,7 @@ fn two_party_successful_swap() {
Origin::signed(B),
A,
hashed_proof.clone(),
75,
BalanceSwapAction::new(75),
1000,
).unwrap();
@@ -136,6 +136,7 @@ fn two_party_successful_swap() {
AtomicSwap::claim_swap(
Origin::signed(A),
proof.to_vec(),
BalanceSwapAction::new(75),
).unwrap();
assert_eq!(Balances::free_balance(A), 100 + 75);
@@ -147,6 +148,7 @@ fn two_party_successful_swap() {
AtomicSwap::claim_swap(
Origin::signed(B),
proof.to_vec(),
BalanceSwapAction::new(50),
).unwrap();
assert_eq!(Balances::free_balance(A), 100 - 50);