예제 #1
0
 def test_constructor_validates_addresses(self, acc_address, other):
     """MsgVote should validate `voter` to be AccAddress."""
     assume(not is_acc_address(other))
     with pytest.raises(InvalidAccAddress):
         MsgVote(proposal_id=1, voter=other, option="")
     A = MsgVote(proposal_id=1, voter=acc_address, option="")
     assert A.voter == acc_address
예제 #2
0
 def test_constructor_validates_addresses(self, acc_address, val_address,
                                          other):
     """MsgExchangeRateVote should validate `feeder` to be AccAddress and `validator`
     to be ValAddress.
     """
     assume(not is_val_address(other) and not is_acc_address(other))
     with pytest.raises(InvalidAccAddress):
         MsgExchangeRateVote(
             exchange_rate=Coin("ukrw", 1000),
             salt="",
             denom="ukrw",
             feeder=other,
             validator=val_address,
         )
     with pytest.raises(InvalidValAddress):
         MsgExchangeRateVote(
             exchange_rate=Coin("ukrw", 1000),
             salt="",
             denom="ukrw",
             feeder=acc_address,
             validator=other,
         )
     A = MsgExchangeRateVote(
         exchange_rate=Coin("ukrw", 1000),
         salt="",
         denom="ukrw",
         feeder=acc_address,
         validator=val_address,
     )
     assert A.feeder == acc_address
     assert A.validator == val_address
예제 #3
0
 def test_constructor_validates_addresses(self, acc_address, val_address,
                                          other):
     """`MsgExchangeRateVote` should validate `feeder` to be AccAddress and `validator`
     to be ValAddress.
     """
     assume(not is_val_address(other) and not is_acc_address(other))
     with pytest.raises(InvalidAccAddress):
         MsgExchangeRatePrevote(
             hash="",
             denom="",
             feeder=other,
             validator=val_address,
         )
     with pytest.raises(InvalidValAddress):
         MsgExchangeRatePrevote(
             hash="",
             denom="",
             feeder=acc_address,
             validator=other,
         )
     A = MsgExchangeRatePrevote(
         hash="",
         denom="",
         feeder=acc_address,
         validator=val_address,
     )
     assert A.feeder == acc_address
     assert A.validator == val_address
예제 #4
0
 def test_generate(self):
     """Test whether random Mnemonic generation works."""
     k = MnemonicKey.generate()
     assert len(k.mnemonic.split()) == 24
     assert k.mnemonic != MnemonicKey.generate().mnemonic
     assert is_acc_address(k.acc_address)
     assert is_val_address(k.val_address)
예제 #5
0
 def test_constructor_validates_addresses(self, acc_address, other):
     """MsgDeposit should validate `depositor` to be AccAddress.
     """
     assume(not is_acc_address(other))
     with pytest.raises(InvalidAccAddress):
         MsgDeposit(proposal_id=1, depositor=other, amount=[])
     A = MsgDeposit(proposal_id=1, depositor=acc_address, amount=[])
     assert A.depositor == acc_address
예제 #6
0
 def test_constructor_validates_addresses(self, acc_address, other):
     """MsgSubmitProposal should validate `proposer` to be AccAddress.
     """
     assume(not is_acc_address(other))
     with pytest.raises(InvalidAccAddress):
         MsgSubmitProposal(content=None, initial_deposit=[], proposer=other)
     A = MsgSubmitProposal(content=None,
                           initial_deposit=[],
                           proposer=acc_address)
     assert A.proposer == acc_address
예제 #7
0
 def test_constructor_validates_addresses(self, acc_address, other):
     """MsgSwap should validate `trader` to be AccAddress.
     """
     assume(not is_acc_address(other))
     with pytest.raises(InvalidAccAddress):
         MsgSwap(trader=other,
                 offer_coin=Coin("uluna", 100),
                 ask_denom="umnt")
     A = MsgSwap(trader=acc_address,
                 offer_coin=Coin("uluna", 100),
                 ask_denom="umnt")
     assert A.trader == acc_address
예제 #8
0
 def test_constructor_validates_addresses(self, acc_address, val_address,
                                          other):
     """MsgDelegateFeedConsent should validate `operator` to be ValAddress and `delegate`
     to be AccAddress.
     """
     assume(not is_val_address(other) and not is_acc_address(other))
     with pytest.raises(InvalidValAddress):
         MsgDelegateFeedConsent(operator=other, delegate=acc_address)
     with pytest.raises(InvalidAccAddress):
         MsgDelegateFeedConsent(operator=val_address, delegate=other)
     A = MsgDelegateFeedConsent(operator=val_address, delegate=acc_address)
     assert A.operator == val_address
     assert A.delegate == acc_address
예제 #9
0
    def test_constructor_validates_addresses(self, acc_address, other):
        """MsgSend should validate both from_address and to_address to be AccAddress.
        """

        assume(not is_acc_address(other))

        with pytest.raises(InvalidAccAddress):
            MsgSend(from_address=acc_address, to_address=other, amount=[])
        with pytest.raises(InvalidAccAddress):
            MsgSend(from_address=other, to_address=acc_address, amount=[])

        A = MsgSend(from_address=acc_address, to_address=acc_address, amount=[])
        assert A.from_address == acc_address
예제 #10
0
    def test_constructor_validates_addresses(self, acc_address, dict_list, other):
        """MsgMultiSend should validate inputs[x].address and outputs[x].address if inputs and outputs
        are passed in as dicts.
        """
        assume(not is_acc_address(other))

        bad = [{"address": acc_address, "coins": []}, {"address": other, "coins": []}]
        with pytest.raises(InvalidAccAddress):
            MsgMultiSend(inputs=bad, outputs=dict_list)
        with pytest.raises(InvalidAccAddress):
            MsgMultiSend(inputs=dict_list, outputs=bad)
        with pytest.raises(InvalidAccAddress):
            MsgMultiSend(inputs=bad, outputs=bad)

        A = MsgMultiSend(inputs=dict_list, outputs=dict_list)
예제 #11
0
    def test_constructor_validates_addresses(self, acc_address, other):
        """MsgModifyWithdrawAddress should validate `delegator_address` and `withdraw_address` to
        be correct AccAddress.
        """

        assume(not is_acc_address(other))
        with pytest.raises(InvalidAccAddress):
            MsgModifyWithdrawAddress(
                delegator_address=other, withdraw_address=acc_address
            )
        with pytest.raises(InvalidAccAddress):
            MsgModifyWithdrawAddress(
                delegator_address=acc_address, withdraw_address=other
            )
        A = MsgModifyWithdrawAddress(
            delegator_address=acc_address, withdraw_address=acc_address
        )
        assert A.delegator_address == acc_address
예제 #12
0
    def test_constructor_validates_addresses(self, acc_address, val_address, other):
        """MsgWithdrawDelegationReward should validate `delegator_address` to be AccAddress
        and `withdraw_address` to be ValAddress.
        """

        assume(not is_acc_address(other) and not is_val_address(other))
        with pytest.raises(InvalidAccAddress):
            MsgWithdrawDelegationReward(
                delegator_address=other, validator_address=val_address
            )
        with pytest.raises(InvalidValAddress):
            MsgWithdrawDelegationReward(
                delegator_address=acc_address, validator_address=other
            )
        A = MsgWithdrawDelegationReward(
            delegator_address=acc_address, validator_address=val_address
        )
        assert A.delegator_address == acc_address
        assert A.validator_address == val_address
예제 #13
0
 def test_constructor_validates_addresses(self, acc_address, val_address,
                                          other):
     """MsgBeginRedelegate should validate `delegator` to be AccAddress, and both
     `validator_src_address` and `validator_dst_address` to be ValAddress.
     """
     assume(not is_acc_address(other) and not is_val_address(other))
     with pytest.raises(InvalidAccAddress):
         MsgBeginRedelegate(
             delegator_address=other,
             validator_src_address=val_address,
             validator_dst_address=val_address,
             amount=None,
         )
     with pytest.raises(InvalidValAddress):
         MsgBeginRedelegate(
             delegator_address=acc_address,
             validator_src_address=other,
             validator_dst_address=val_address,
             amount=None,
         )
     with pytest.raises(InvalidValAddress):
         MsgBeginRedelegate(
             delegator_address=acc_address,
             validator_src_address=val_address,
             validator_dst_address=other,
             amount=None,
         )
     A = MsgBeginRedelegate(
         delegator_address=acc_address,
         validator_src_address=val_address,
         validator_dst_address=val_address,
         amount=None,
     )
     assert A.delegator_address == acc_address
     assert A.validator_src_address == val_address
     assert A.validator_dst_address == val_address