Skip to content

Commit 91a5620

Browse files
committed
Use ustake denom as example for staking
1 parent a3717ec commit 91a5620

File tree

5 files changed

+43
-43
lines changed

5 files changed

+43
-43
lines changed

contracts/reflect/src/contract.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ mod tests {
218218
CustomMsg::Debug("Hi, Dad!".to_string()).into(),
219219
StakingMsg::Delegate {
220220
validator: HumanAddr::from("validator"),
221-
amount: coin(100, "stake"),
221+
amount: coin(100, "ustake"),
222222
}
223223
.into(),
224224
];

contracts/reflect/tests/integration.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ fn reflect() {
9595
CustomMsg::Debug("Hi, Dad!".to_string()).into(),
9696
StakingMsg::Delegate {
9797
validator: HumanAddr::from("validator"),
98-
amount: coin(100, "stake"),
98+
amount: coin(100, "ustake"),
9999
}
100100
.into(),
101101
];

contracts/staking/src/contract.rs

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -477,12 +477,12 @@ mod tests {
477477
}
478478

479479
fn set_validator(querier: &mut MockQuerier) {
480-
querier.update_staking("stake", &[sample_validator(DEFAULT_VALIDATOR)], &[]);
480+
querier.update_staking("ustake", &[sample_validator(DEFAULT_VALIDATOR)], &[]);
481481
}
482482

483483
fn set_delegation(querier: &mut MockQuerier, amount: u128, denom: &str) {
484484
querier.update_staking(
485-
"stake",
485+
"ustake",
486486
&[sample_validator(DEFAULT_VALIDATOR)],
487487
&[sample_delegation(DEFAULT_VALIDATOR, coin(amount, denom))],
488488
);
@@ -529,7 +529,7 @@ mod tests {
529529
fn initialization_with_missing_validator() {
530530
let mut deps = mock_dependencies(20, &[]);
531531
deps.querier
532-
.update_staking("stake", &[sample_validator("john")], &[]);
532+
.update_staking("ustake", &[sample_validator("john")], &[]);
533533

534534
let creator = HumanAddr::from("creator");
535535
let msg = InitMsg {
@@ -556,7 +556,7 @@ mod tests {
556556
fn proper_initialization() {
557557
let mut deps = mock_dependencies(20, &[]);
558558
deps.querier.update_staking(
559-
"stake",
559+
"ustake",
560560
&[
561561
sample_validator("john"),
562562
sample_validator("mary"),
@@ -601,7 +601,7 @@ mod tests {
601601
assert_eq!(invest.min_withdrawal, msg.min_withdrawal);
602602

603603
assert_eq!(invest.token_supply, Uint128(0));
604-
assert_eq!(invest.staked_tokens, coin(0, "stake"));
604+
assert_eq!(invest.staked_tokens, coin(0, "ustake"));
605605
assert_eq!(invest.nominal_value, Decimal::one());
606606
}
607607

@@ -621,7 +621,7 @@ mod tests {
621621
// let's bond some tokens now
622622
let bob = HumanAddr::from("bob");
623623
let bond_msg = HandleMsg::Bond {};
624-
let env = mock_env(&deps.api, &bob, &[coin(10, "random"), coin(1000, "stake")]);
624+
let env = mock_env(&deps.api, &bob, &[coin(10, "random"), coin(1000, "ustake")]);
625625

626626
// try to bond and make sure we trigger delegation
627627
let res = handle(&mut deps, env, bond_msg).unwrap();
@@ -630,7 +630,7 @@ mod tests {
630630
match delegate {
631631
CosmosMsg::Staking(StakingMsg::Delegate { validator, amount }) => {
632632
assert_eq!(validator.as_str(), DEFAULT_VALIDATOR);
633-
assert_eq!(amount, &coin(1000, "stake"));
633+
assert_eq!(amount, &coin(1000, "ustake"));
634634
}
635635
_ => panic!("Unexpected message: {:?}", delegate),
636636
}
@@ -642,7 +642,7 @@ mod tests {
642642
let res = query(&deps, QueryMsg::Investment {}).unwrap();
643643
let invest: InvestmentResponse = from_binary(&res).unwrap();
644644
assert_eq!(invest.token_supply, Uint128(1000));
645-
assert_eq!(invest.staked_tokens, coin(1000, "stake"));
645+
assert_eq!(invest.staked_tokens, coin(1000, "ustake"));
646646
assert_eq!(invest.nominal_value, Decimal::one());
647647
}
648648

@@ -662,49 +662,49 @@ mod tests {
662662
// let's bond some tokens now
663663
let bob = HumanAddr::from("bob");
664664
let bond_msg = HandleMsg::Bond {};
665-
let env = mock_env(&deps.api, &bob, &[coin(10, "random"), coin(1000, "stake")]);
665+
let env = mock_env(&deps.api, &bob, &[coin(10, "random"), coin(1000, "ustake")]);
666666
let contract_addr = deps.api.human_address(&env.contract.address).unwrap();
667667
let res = handle(&mut deps, env, bond_msg).unwrap();
668668
assert_eq!(1, res.messages.len());
669669

670670
// update the querier with new bond
671-
set_delegation(&mut deps.querier, 1000, "stake");
671+
set_delegation(&mut deps.querier, 1000, "ustake");
672672

673673
// fake a reinvestment (this must be sent by the contract itself)
674674
let rebond_msg = HandleMsg::_BondAllTokens {};
675675
let env = mock_env(&deps.api, &contract_addr, &[]);
676676
deps.querier
677-
.update_balance(&contract_addr, coins(500, "stake"));
677+
.update_balance(&contract_addr, coins(500, "ustake"));
678678
let _ = handle(&mut deps, env, rebond_msg).unwrap();
679679

680680
// update the querier with new bond
681-
set_delegation(&mut deps.querier, 1500, "stake");
681+
set_delegation(&mut deps.querier, 1500, "ustake");
682682

683683
// we should now see 1000 issues and 1500 bonded (and a price of 1.5)
684684
let res = query(&deps, QueryMsg::Investment {}).unwrap();
685685
let invest: InvestmentResponse = from_binary(&res).unwrap();
686686
assert_eq!(invest.token_supply, Uint128(1000));
687-
assert_eq!(invest.staked_tokens, coin(1500, "stake"));
687+
assert_eq!(invest.staked_tokens, coin(1500, "ustake"));
688688
let ratio = Decimal::from_str("1.5").unwrap();
689689
assert_eq!(invest.nominal_value, ratio);
690690

691691
// we bond some other tokens and get a different issuance price (maintaining the ratio)
692692
let alice = HumanAddr::from("alice");
693693
let bond_msg = HandleMsg::Bond {};
694-
let env = mock_env(&deps.api, &alice, &[coin(3000, "stake")]);
694+
let env = mock_env(&deps.api, &alice, &[coin(3000, "ustake")]);
695695
let res = handle(&mut deps, env, bond_msg).unwrap();
696696
assert_eq!(1, res.messages.len());
697697

698698
// update the querier with new bond
699-
set_delegation(&mut deps.querier, 3000, "stake");
699+
set_delegation(&mut deps.querier, 3000, "ustake");
700700

701701
// alice should have gotten 2000 DRV for the 3000 stake, keeping the ratio at 1.5
702702
assert_eq!(get_balance(&deps, &alice), Uint128(2000));
703703

704704
let res = query(&deps, QueryMsg::Investment {}).unwrap();
705705
let invest: InvestmentResponse = from_binary(&res).unwrap();
706706
assert_eq!(invest.token_supply, Uint128(3000));
707-
assert_eq!(invest.staked_tokens, coin(4500, "stake"));
707+
assert_eq!(invest.staked_tokens, coin(4500, "ustake"));
708708
assert_eq!(invest.nominal_value, ratio);
709709
}
710710

@@ -729,7 +729,7 @@ mod tests {
729729
// try to bond and make sure we trigger delegation
730730
let res = handle(&mut deps, env, bond_msg);
731731
match res.unwrap_err() {
732-
StdError::GenericErr { msg, .. } => assert_eq!(msg, "No stake tokens sent"),
732+
StdError::GenericErr { msg, .. } => assert_eq!(msg, "No ustake tokens sent"),
733733
e => panic!("Expected wrong denom error, got: {:?}", e),
734734
};
735735
}
@@ -750,24 +750,24 @@ mod tests {
750750
// let's bond some tokens now
751751
let bob = HumanAddr::from("bob");
752752
let bond_msg = HandleMsg::Bond {};
753-
let env = mock_env(&deps.api, &bob, &[coin(10, "random"), coin(1000, "stake")]);
753+
let env = mock_env(&deps.api, &bob, &[coin(10, "random"), coin(1000, "ustake")]);
754754
let contract_addr = deps.api.human_address(&env.contract.address).unwrap();
755755
let res = handle(&mut deps, env, bond_msg).unwrap();
756756
assert_eq!(1, res.messages.len());
757757

758758
// update the querier with new bond
759-
set_delegation(&mut deps.querier, 1000, "stake");
759+
set_delegation(&mut deps.querier, 1000, "ustake");
760760

761761
// fake a reinvestment (this must be sent by the contract itself)
762762
// after this, we see 1000 issues and 1500 bonded (and a price of 1.5)
763763
let rebond_msg = HandleMsg::_BondAllTokens {};
764764
let env = mock_env(&deps.api, &contract_addr, &[]);
765765
deps.querier
766-
.update_balance(&contract_addr, coins(500, "stake"));
766+
.update_balance(&contract_addr, coins(500, "ustake"));
767767
let _ = handle(&mut deps, env, rebond_msg).unwrap();
768768

769769
// update the querier with new bond, lower balance
770-
set_delegation(&mut deps.querier, 1500, "stake");
770+
set_delegation(&mut deps.querier, 1500, "ustake");
771771
deps.querier.update_balance(&contract_addr, vec![]);
772772

773773
// creator now tries to unbond these tokens - this must fail
@@ -797,13 +797,13 @@ mod tests {
797797
match delegate {
798798
CosmosMsg::Staking(StakingMsg::Undelegate { validator, amount }) => {
799799
assert_eq!(validator.as_str(), DEFAULT_VALIDATOR);
800-
assert_eq!(amount, &coin(bobs_claim.u128(), "stake"));
800+
assert_eq!(amount, &coin(bobs_claim.u128(), "ustake"));
801801
}
802802
_ => panic!("Unexpected message: {:?}", delegate),
803803
}
804804

805805
// update the querier with new bond, lower balance
806-
set_delegation(&mut deps.querier, 690, "stake");
806+
set_delegation(&mut deps.querier, 690, "ustake");
807807

808808
// check balances
809809
assert_eq!(get_balance(&deps, &bob), bobs_balance);
@@ -818,7 +818,7 @@ mod tests {
818818
let invest: InvestmentResponse = from_binary(&res).unwrap();
819819
print!("invest: {:?}", &invest);
820820
assert_eq!(invest.token_supply, bobs_balance + owner_cut);
821-
assert_eq!(invest.staked_tokens, coin(690, "stake")); // 1500 - 810
821+
assert_eq!(invest.staked_tokens, coin(690, "ustake")); // 1500 - 810
822822
assert_eq!(invest.nominal_value, ratio);
823823
}
824824
}

contracts/staking/tests/integration.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ fn sample_validator<U: Into<HumanAddr>>(addr: U) -> Validator {
4545
fn initialization_with_missing_validator() {
4646
let mut ext = mock_dependencies(20, &[]);
4747
ext.querier
48-
.update_staking("stake", &[sample_validator("john")], &[]);
48+
.update_staking("ustake", &[sample_validator("john")], &[]);
4949
let mut deps = Instance::from_code(WASM, ext, 500_000).unwrap();
5050

5151
let creator = HumanAddr::from("creator");
@@ -74,7 +74,7 @@ fn proper_initialization() {
7474
// we need to use the verbose approach here to customize the querier with staking info
7575
let mut ext = mock_dependencies(20, &[]);
7676
ext.querier.update_staking(
77-
"stake",
77+
"ustake",
7878
&[
7979
sample_validator("john"),
8080
sample_validator("mary"),
@@ -139,7 +139,7 @@ fn proper_initialization() {
139139
assert_eq!(invest.min_withdrawal, msg.min_withdrawal);
140140

141141
assert_eq!(invest.token_supply, Uint128(0));
142-
assert_eq!(invest.staked_tokens, coin(0, "stake"));
142+
assert_eq!(invest.staked_tokens, coin(0, "ustake"));
143143
assert_eq!(invest.nominal_value, Decimal::one());
144144
}
145145

packages/std/src/mock.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ mod test {
477477
max_change_rate: Decimal::permille(5),
478478
};
479479

480-
let staking = StakingQuerier::new("stake", &[val1.clone(), val2.clone()], &[]);
480+
let staking = StakingQuerier::new("ustake", &[val1.clone(), val2.clone()], &[]);
481481

482482
// one match
483483
let raw = staking
@@ -528,38 +528,38 @@ mod test {
528528
let del1a = FullDelegation {
529529
delegator: user_a.clone(),
530530
validator: val1.clone(),
531-
amount: coin(100, "stake"),
532-
can_redelegate: coin(100, "stake"),
533-
accumulated_rewards: coin(5, "stake"),
531+
amount: coin(100, "ustake"),
532+
can_redelegate: coin(100, "ustake"),
533+
accumulated_rewards: coin(5, "ustake"),
534534
};
535535
let del2a = FullDelegation {
536536
delegator: user_a.clone(),
537537
validator: val2.clone(),
538-
amount: coin(500, "stake"),
539-
can_redelegate: coin(500, "stake"),
540-
accumulated_rewards: coin(20, "stake"),
538+
amount: coin(500, "ustake"),
539+
can_redelegate: coin(500, "ustake"),
540+
accumulated_rewards: coin(20, "ustake"),
541541
};
542542

543543
// note we cannot have multiple delegations on one validator, they are collapsed into one
544544
let del1b = FullDelegation {
545545
delegator: user_b.clone(),
546546
validator: val1.clone(),
547-
amount: coin(500, "stake"),
548-
can_redelegate: coin(0, "stake"),
549-
accumulated_rewards: coin(0, "stake"),
547+
amount: coin(500, "ustake"),
548+
can_redelegate: coin(0, "ustake"),
549+
accumulated_rewards: coin(0, "ustake"),
550550
};
551551

552552
// and another one on val2
553553
let del2c = FullDelegation {
554554
delegator: user_c.clone(),
555555
validator: val2.clone(),
556-
amount: coin(8888, "stake"),
557-
can_redelegate: coin(4567, "stake"),
558-
accumulated_rewards: coin(900, "stake"),
556+
amount: coin(8888, "ustake"),
557+
can_redelegate: coin(4567, "ustake"),
558+
accumulated_rewards: coin(900, "ustake"),
559559
};
560560

561561
let staking = StakingQuerier::new(
562-
"stake",
562+
"ustake",
563563
&[],
564564
&[del1a.clone(), del1b.clone(), del2a.clone(), del2c.clone()],
565565
);

0 commit comments

Comments
 (0)