def test_transfer_success(self): ACCOUNT_AMOUNT1 = 1000 ACCOUNT_AMOUNT2 = 500 TRANSFER_VALUE = ACCOUNT_AMOUNT1 self.send_transaction( TokenMethod.TRANSFER, TokenClient.get_transfer_payload(self.account_address2, TRANSFER_VALUE), [self.account_address1, self.account_address2]) self.expect_get({ self.account_address1: TokenClient.get_account_model(ACCOUNT_AMOUNT1) }) self.expect_get({ self.account_address2: TokenClient.get_account_model(ACCOUNT_AMOUNT2) }) self.expect_set({ self.account_address1: TokenClient.get_account_model(ACCOUNT_AMOUNT1 - TRANSFER_VALUE), self.account_address2: TokenClient.get_account_model(ACCOUNT_AMOUNT2 + TRANSFER_VALUE) }) self.expect_ok()
def test_transfer_fail_no_balance(self): ACCOUNT_AMOUNT1 = 200 ACCOUNT_AMOUNT2 = 500 TRANSFER_VALUE = ACCOUNT_AMOUNT1 + 1 self.send_transaction( TokenMethod.TRANSFER, TokenClient.get_transfer_payload(self.account_address2, TRANSFER_VALUE), [self.account_address1, self.account_address2]) self.expect_get({ self.account_address1: TokenClient.get_account_model(ACCOUNT_AMOUNT1) }) self.expect_get({ self.account_address2: TokenClient.get_account_model(ACCOUNT_AMOUNT2) }) self.expect_invalid_transaction()
def test_transfer_fail_no_state_address2(self): ACCOUNT_AMOUNT1 = 500 TRANSFER_VALUE = 200 self.send_transaction( TokenMethod.TRANSFER, TokenClient.get_transfer_payload(self.account_address2, TRANSFER_VALUE), [self.account_address1, self.account_address2]) self.expect_get({ self.account_address1: TokenClient.get_account_model(ACCOUNT_AMOUNT1) }) self.expect_get({self.account_address2: None}) self.expect_set({ self.account_address1: TokenClient.get_account_model(ACCOUNT_AMOUNT1 - TRANSFER_VALUE), self.account_address2: TokenClient.get_account_model(0 + TRANSFER_VALUE) }) self.expect_ok()
def test_transfer_fail_to_zeroaddress(self): ACCOUNT_AMOUNT1 = 500 TRANSFER_VALUE = 200 self.send_transaction( TokenMethod.TRANSFER, TokenClient.get_transfer_payload( self.handler.make_address(ZERO_ADDRESS), TRANSFER_VALUE), [self.account_address1, self.account_address2]) self.expect_get({ self.account_address1: TokenClient.get_account_model(ACCOUNT_AMOUNT1) }) self.expect_invalid_transaction()