Example #1
0
    def test_transaction_invalid_address(self):
        wallet = IcxWallet()
        wallet.value = 1
        wallet._IcxWallet__address = "hx2983"

        params = wallet.create_icx_origin()
        self.__test_wallet_exception(params, TransactionInvalidAddressError)

        params = wallet.create_icx_origin_v3()
        self.__test_wallet_exception(params, TransactionInvalidAddressError)
Example #2
0
    def test_transaction_invalid_wrong_nid(self):
        wallet = IcxWallet()
        wallet.value = 1
        wallet.nid = '0x5'

        ChannelProperty().nid = '0x3'

        param3 = wallet.create_icx_origin_v3()

        exception: TransactionInvalidNoNidError = self.__test_wallet_exception(param3, TransactionInvalidNoNidError)
        self.assertEqual(exception.expected_nid, ChannelProperty().nid)
        self.assertEqual(exception.nid, wallet.nid)
Example #3
0
    def test_transcation_invalid_address_not_match(self):
        wallet = IcxWallet()
        wallet.value = 1

        paramsv2 = wallet.create_icx_origin()
        paramsv3 = wallet.create_icx_origin_v3()

        another_wallet = IcxWallet()

        # sign hash with another wallet's private key
        paramsv2['signature'] = another_wallet.create_signature(
            self.hash_generator.generate_hash(paramsv2))
        paramsv3['signature'] = another_wallet.create_signature(
            self.hash_generator.generate_hash(paramsv3))

        logging.info("address: " + wallet.address)
        logging.info("another addres: " + another_wallet.address)

        ChannelProperty().nid = '0x3'

        exception: TransactionInvalidAddressNotMatchError = self.__test_wallet_exception(
            paramsv2, TransactionInvalidAddressNotMatchError)
        self.assertEquals(exception.address, wallet.address)
        self.assertEquals(exception.expected_address, another_wallet.address)

        exception: TransactionInvalidAddressNotMatchError = self.__test_wallet_exception(
            paramsv3, TransactionInvalidAddressNotMatchError)
        self.assertEquals(exception.address, wallet.address)
        self.assertEquals(exception.expected_address, another_wallet.address)

        # These codes below affects hash generation.
        # V3 params does not have `txHash`.
        # So it cannot raise `HashNotMatch` Exception but `AddressNotMatch`
        paramsv3 = wallet.create_icx_origin_v3()
        paramsv3["timestamp"] = hex(utils.get_now_time_stamp())

        exception: TransactionInvalidAddressNotMatchError = self.__test_wallet_exception(
            paramsv3, TransactionInvalidAddressNotMatchError)
        self.assertEquals(exception.address, wallet.address)