|
@@ -8,11 +8,21 @@ async fn deposit_and_transfer_and_withdrawal() {
|
|
|
let fee = "fee".parse::<AccountId>().expect("account");
|
|
|
let (assets, ledger) = get_instance().await;
|
|
|
|
|
|
- deposit(&ledger, &source, assets.amount(2, 1000).expect("amount")).await;
|
|
|
- deposit(&ledger, &source, assets.amount(2, 2000).expect("amount")).await;
|
|
|
+ deposit(
|
|
|
+ &ledger,
|
|
|
+ &source,
|
|
|
+ assets.amount_by_and_cents(2, 1000).expect("amount"),
|
|
|
+ )
|
|
|
+ .await;
|
|
|
+ deposit(
|
|
|
+ &ledger,
|
|
|
+ &source,
|
|
|
+ assets.amount_by_and_cents(2, 2000).expect("amount"),
|
|
|
+ )
|
|
|
+ .await;
|
|
|
|
|
|
assert_eq!(
|
|
|
- vec![assets.amount(2, 3000).expect("amount")],
|
|
|
+ vec![assets.amount_by_and_cents(2, 3000).expect("amount")],
|
|
|
ledger.get_balance(&source).await.expect("balance")
|
|
|
);
|
|
|
|
|
@@ -20,25 +30,34 @@ async fn deposit_and_transfer_and_withdrawal() {
|
|
|
.new_transaction(
|
|
|
"Exchange one".to_owned(),
|
|
|
Status::Settled,
|
|
|
- vec![(source.clone(), assets.amount(2, 1300).expect("amount"))],
|
|
|
+ vec![(
|
|
|
+ source.clone(),
|
|
|
+ assets.amount_by_and_cents(2, 1300).expect("amount"),
|
|
|
+ )],
|
|
|
vec![
|
|
|
- (dest.clone(), assets.amount(2, 1250).expect("amount")),
|
|
|
- (fee.clone(), assets.amount(2, 50).expect("amount")),
|
|
|
+ (
|
|
|
+ dest.clone(),
|
|
|
+ assets.amount_by_and_cents(2, 1250).expect("amount"),
|
|
|
+ ),
|
|
|
+ (
|
|
|
+ fee.clone(),
|
|
|
+ assets.amount_by_and_cents(2, 50).expect("amount"),
|
|
|
+ ),
|
|
|
],
|
|
|
)
|
|
|
.await
|
|
|
.expect("valid tx");
|
|
|
|
|
|
assert_eq!(
|
|
|
- vec![assets.amount(2, 1700).expect("amount")],
|
|
|
+ vec![assets.amount_by_and_cents(2, 1700).expect("amount")],
|
|
|
ledger.get_balance(&source).await.expect("balance")
|
|
|
);
|
|
|
assert_eq!(
|
|
|
- vec![assets.amount(2, 1250).expect("amount")],
|
|
|
+ vec![assets.amount_by_and_cents(2, 1250).expect("amount")],
|
|
|
ledger.get_balance(&dest).await.expect("balance")
|
|
|
);
|
|
|
assert_eq!(
|
|
|
- vec![assets.amount(2, 50).expect("amount")],
|
|
|
+ vec![assets.amount_by_and_cents(2, 50).expect("amount")],
|
|
|
ledger.get_balance(&fee).await.expect("balance")
|
|
|
);
|
|
|
|
|
@@ -46,7 +65,7 @@ async fn deposit_and_transfer_and_withdrawal() {
|
|
|
&ledger,
|
|
|
&source,
|
|
|
Status::Settled,
|
|
|
- assets.amount(2, 1700).expect("amount")
|
|
|
+ assets.amount_by_and_cents(2, 1700).expect("amount")
|
|
|
)
|
|
|
.await
|
|
|
.is_ok());
|
|
@@ -57,11 +76,11 @@ async fn deposit_and_transfer_and_withdrawal() {
|
|
|
.expect("balance")
|
|
|
.is_empty());
|
|
|
assert_eq!(
|
|
|
- vec![assets.amount(2, 1250).expect("amount")],
|
|
|
+ vec![assets.amount_by_and_cents(2, 1250).expect("amount")],
|
|
|
ledger.get_balance(&dest).await.expect("balance")
|
|
|
);
|
|
|
assert_eq!(
|
|
|
- vec![assets.amount(2, 50).expect("amount")],
|
|
|
+ vec![assets.amount_by_and_cents(2, 50).expect("amount")],
|
|
|
ledger.get_balance(&fee).await.expect("balance")
|
|
|
);
|
|
|
}
|
|
@@ -73,11 +92,21 @@ async fn fail_to_overwithdrawal() {
|
|
|
let fee = "fee".parse::<AccountId>().expect("account");
|
|
|
let (assets, ledger) = get_instance().await;
|
|
|
|
|
|
- deposit(&ledger, &source, assets.amount(2, 1000).expect("amount")).await;
|
|
|
- deposit(&ledger, &source, assets.amount(2, 2000).expect("amount")).await;
|
|
|
+ deposit(
|
|
|
+ &ledger,
|
|
|
+ &source,
|
|
|
+ assets.amount_by_and_cents(2, 1000).expect("amount"),
|
|
|
+ )
|
|
|
+ .await;
|
|
|
+ deposit(
|
|
|
+ &ledger,
|
|
|
+ &source,
|
|
|
+ assets.amount_by_and_cents(2, 2000).expect("amount"),
|
|
|
+ )
|
|
|
+ .await;
|
|
|
|
|
|
assert_eq!(
|
|
|
- vec![assets.amount(2, 3000).expect("amount")],
|
|
|
+ vec![assets.amount_by_and_cents(2, 3000).expect("amount")],
|
|
|
ledger.get_balance(&source).await.expect("balance")
|
|
|
);
|
|
|
|
|
@@ -85,25 +114,34 @@ async fn fail_to_overwithdrawal() {
|
|
|
.new_transaction(
|
|
|
"Exchange one".to_owned(),
|
|
|
Status::Settled,
|
|
|
- vec![(source.clone(), assets.amount(2, 1300).expect("amount"))],
|
|
|
+ vec![(
|
|
|
+ source.clone(),
|
|
|
+ assets.amount_by_and_cents(2, 1300).expect("amount"),
|
|
|
+ )],
|
|
|
vec![
|
|
|
- (dest.clone(), assets.amount(2, 1250).expect("amount")),
|
|
|
- (fee.clone(), assets.amount(2, 50).expect("amount")),
|
|
|
+ (
|
|
|
+ dest.clone(),
|
|
|
+ assets.amount_by_and_cents(2, 1250).expect("amount"),
|
|
|
+ ),
|
|
|
+ (
|
|
|
+ fee.clone(),
|
|
|
+ assets.amount_by_and_cents(2, 50).expect("amount"),
|
|
|
+ ),
|
|
|
],
|
|
|
)
|
|
|
.await
|
|
|
.expect("valid tx");
|
|
|
|
|
|
assert_eq!(
|
|
|
- vec![assets.amount(2, 1700).expect("amount")],
|
|
|
+ vec![assets.amount_by_and_cents(2, 1700).expect("amount")],
|
|
|
ledger.get_balance(&source).await.expect("balance")
|
|
|
);
|
|
|
assert_eq!(
|
|
|
- vec![assets.amount(2, 1250).expect("amount")],
|
|
|
+ vec![assets.amount_by_and_cents(2, 1250).expect("amount")],
|
|
|
ledger.get_balance(&dest).await.expect("balance")
|
|
|
);
|
|
|
assert_eq!(
|
|
|
- vec![assets.amount(2, 50).expect("amount")],
|
|
|
+ vec![assets.amount_by_and_cents(2, 50).expect("amount")],
|
|
|
ledger.get_balance(&fee).await.expect("balance")
|
|
|
);
|
|
|
|
|
@@ -111,21 +149,21 @@ async fn fail_to_overwithdrawal() {
|
|
|
&ledger,
|
|
|
&source,
|
|
|
Status::Settled,
|
|
|
- assets.amount(2, 170000).expect("amount")
|
|
|
+ assets.amount_by_and_cents(2, 170000).expect("amount")
|
|
|
)
|
|
|
.await
|
|
|
.is_err());
|
|
|
|
|
|
assert_eq!(
|
|
|
- vec![assets.amount(2, 1700).expect("amount")],
|
|
|
+ vec![assets.amount_by_and_cents(2, 1700).expect("amount")],
|
|
|
ledger.get_balance(&source).await.expect("balance")
|
|
|
);
|
|
|
assert_eq!(
|
|
|
- vec![assets.amount(2, 1250).expect("amount")],
|
|
|
+ vec![assets.amount_by_and_cents(2, 1250).expect("amount")],
|
|
|
ledger.get_balance(&dest).await.expect("balance")
|
|
|
);
|
|
|
assert_eq!(
|
|
|
- vec![assets.amount(2, 50).expect("amount")],
|
|
|
+ vec![assets.amount_by_and_cents(2, 50).expect("amount")],
|
|
|
ledger.get_balance(&fee).await.expect("balance")
|
|
|
);
|
|
|
}
|
|
@@ -137,11 +175,21 @@ async fn cancelled_withdrawal() {
|
|
|
let fee = "fee".parse::<AccountId>().expect("account");
|
|
|
let (assets, ledger) = get_instance().await;
|
|
|
|
|
|
- deposit(&ledger, &source, assets.amount(2, 1000).expect("amount")).await;
|
|
|
- deposit(&ledger, &source, assets.amount(2, 2000).expect("amount")).await;
|
|
|
+ deposit(
|
|
|
+ &ledger,
|
|
|
+ &source,
|
|
|
+ assets.amount_by_and_cents(2, 1000).expect("amount"),
|
|
|
+ )
|
|
|
+ .await;
|
|
|
+ deposit(
|
|
|
+ &ledger,
|
|
|
+ &source,
|
|
|
+ assets.amount_by_and_cents(2, 2000).expect("amount"),
|
|
|
+ )
|
|
|
+ .await;
|
|
|
|
|
|
assert_eq!(
|
|
|
- vec![assets.amount(2, 3000).expect("amount")],
|
|
|
+ vec![assets.amount_by_and_cents(2, 3000).expect("amount")],
|
|
|
ledger.get_balance(&source).await.expect("balance")
|
|
|
);
|
|
|
|
|
@@ -149,25 +197,34 @@ async fn cancelled_withdrawal() {
|
|
|
.new_transaction(
|
|
|
"Exchange one".to_owned(),
|
|
|
Status::Settled,
|
|
|
- vec![(source.clone(), assets.amount(2, 1300).expect("amount"))],
|
|
|
+ vec![(
|
|
|
+ source.clone(),
|
|
|
+ assets.amount_by_and_cents(2, 1300).expect("amount"),
|
|
|
+ )],
|
|
|
vec![
|
|
|
- (dest.clone(), assets.amount(2, 1250).expect("amount")),
|
|
|
- (fee.clone(), assets.amount(2, 50).expect("amount")),
|
|
|
+ (
|
|
|
+ dest.clone(),
|
|
|
+ assets.amount_by_and_cents(2, 1250).expect("amount"),
|
|
|
+ ),
|
|
|
+ (
|
|
|
+ fee.clone(),
|
|
|
+ assets.amount_by_and_cents(2, 50).expect("amount"),
|
|
|
+ ),
|
|
|
],
|
|
|
)
|
|
|
.await
|
|
|
.expect("valid tx");
|
|
|
|
|
|
assert_eq!(
|
|
|
- vec![assets.amount(2, 1700).expect("amount")],
|
|
|
+ vec![assets.amount_by_and_cents(2, 1700).expect("amount")],
|
|
|
ledger.get_balance(&source).await.expect("balance")
|
|
|
);
|
|
|
assert_eq!(
|
|
|
- vec![assets.amount(2, 1250).expect("amount")],
|
|
|
+ vec![assets.amount_by_and_cents(2, 1250).expect("amount")],
|
|
|
ledger.get_balance(&dest).await.expect("balance")
|
|
|
);
|
|
|
assert_eq!(
|
|
|
- vec![assets.amount(2, 50).expect("amount")],
|
|
|
+ vec![assets.amount_by_and_cents(2, 50).expect("amount")],
|
|
|
ledger.get_balance(&fee).await.expect("balance")
|
|
|
);
|
|
|
|
|
@@ -175,7 +232,7 @@ async fn cancelled_withdrawal() {
|
|
|
&ledger,
|
|
|
&source,
|
|
|
Status::Pending,
|
|
|
- assets.amount(2, 1700).expect("amount"),
|
|
|
+ assets.amount_by_and_cents(2, 1700).expect("amount"),
|
|
|
)
|
|
|
.await
|
|
|
.expect("valid tx");
|
|
@@ -186,11 +243,11 @@ async fn cancelled_withdrawal() {
|
|
|
.expect("balance")
|
|
|
.is_empty());
|
|
|
assert_eq!(
|
|
|
- vec![assets.amount(2, 1250).expect("amount")],
|
|
|
+ vec![assets.amount_by_and_cents(2, 1250).expect("amount")],
|
|
|
ledger.get_balance(&dest).await.expect("balance")
|
|
|
);
|
|
|
assert_eq!(
|
|
|
- vec![assets.amount(2, 50).expect("amount")],
|
|
|
+ vec![assets.amount_by_and_cents(2, 50).expect("amount")],
|
|
|
ledger.get_balance(&fee).await.expect("balance")
|
|
|
);
|
|
|
|
|
@@ -200,16 +257,16 @@ async fn cancelled_withdrawal() {
|
|
|
.expect("valid tx");
|
|
|
|
|
|
assert_eq!(
|
|
|
- vec![assets.amount(2, 1700).expect("amount")],
|
|
|
+ vec![assets.amount_by_and_cents(2, 1700).expect("amount")],
|
|
|
ledger.get_balance(&source).await.expect("balance")
|
|
|
);
|
|
|
|
|
|
assert_eq!(
|
|
|
- vec![assets.amount(2, 1250).expect("amount")],
|
|
|
+ vec![assets.amount_by_and_cents(2, 1250).expect("amount")],
|
|
|
ledger.get_balance(&dest).await.expect("balance")
|
|
|
);
|
|
|
assert_eq!(
|
|
|
- vec![assets.amount(2, 50).expect("amount")],
|
|
|
+ vec![assets.amount_by_and_cents(2, 50).expect("amount")],
|
|
|
ledger.get_balance(&fee).await.expect("balance")
|
|
|
);
|
|
|
}
|
|
@@ -219,15 +276,20 @@ async fn negative_withdrawal() {
|
|
|
let source = "account1".parse::<AccountId>().expect("account");
|
|
|
let (assets, ledger) = get_instance().await;
|
|
|
|
|
|
- deposit(&ledger, &source, assets.amount(2, -1000).expect("amount")).await;
|
|
|
+ deposit(
|
|
|
+ &ledger,
|
|
|
+ &source,
|
|
|
+ assets.amount_by_and_cents(2, -1000).expect("amount"),
|
|
|
+ )
|
|
|
+ .await;
|
|
|
|
|
|
assert_eq!(
|
|
|
- vec![assets.amount(2, -1000).expect("amount")],
|
|
|
+ vec![assets.amount_by_and_cents(2, -1000).expect("amount")],
|
|
|
ledger.get_balance(&source).await.expect("balance")
|
|
|
);
|
|
|
|
|
|
assert_eq!(
|
|
|
- vec![assets.amount(2, -1000).expect("amount")],
|
|
|
+ vec![assets.amount_by_and_cents(2, -1000).expect("amount")],
|
|
|
ledger.get_balance(&source).await.expect("balance")
|
|
|
);
|
|
|
|
|
@@ -235,7 +297,7 @@ async fn negative_withdrawal() {
|
|
|
&ledger,
|
|
|
&source,
|
|
|
Status::Settled,
|
|
|
- assets.amount(2, -1000).expect("amount"),
|
|
|
+ assets.amount_by_and_cents(2, -1000).expect("amount"),
|
|
|
)
|
|
|
.await
|
|
|
.is_err());
|
|
@@ -244,7 +306,7 @@ async fn negative_withdrawal() {
|
|
|
&ledger,
|
|
|
&source,
|
|
|
Status::Settled,
|
|
|
- assets.amount(2, -1).expect("amount"),
|
|
|
+ assets.amount_by_and_cents(2, -1).expect("amount"),
|
|
|
)
|
|
|
.await
|
|
|
.is_err());
|
|
@@ -253,7 +315,7 @@ async fn negative_withdrawal() {
|
|
|
&ledger,
|
|
|
&source,
|
|
|
Status::Settled,
|
|
|
- assets.amount(2, 0).expect("amount"),
|
|
|
+ assets.amount_by_and_cents(2, 0).expect("amount"),
|
|
|
)
|
|
|
.await
|
|
|
.is_err());
|
|
@@ -262,13 +324,13 @@ async fn negative_withdrawal() {
|
|
|
&ledger,
|
|
|
&source,
|
|
|
Status::Settled,
|
|
|
- assets.amount(2, 10).expect("amount"),
|
|
|
+ assets.amount_by_and_cents(2, 10).expect("amount"),
|
|
|
)
|
|
|
.await
|
|
|
.is_err());
|
|
|
|
|
|
assert_eq!(
|
|
|
- vec![assets.amount(2, -1000).expect("amount")],
|
|
|
+ vec![assets.amount_by_and_cents(2, -1000).expect("amount")],
|
|
|
ledger.get_balance(&source).await.expect("balance")
|
|
|
);
|
|
|
}
|