mirror of
https://github.com/FlipsideCrypto/web3.py.git
synced 2026-02-06 10:56:47 +00:00
Merge pull request #116 from 4gn3s/fix_default_account_for_tx
Closes #115 defaultAccount used as transaction from
This commit is contained in:
commit
791e653405
@ -63,20 +63,33 @@ def test_transacting_with_contract_with_arguments(web3_tester,
|
||||
assert final_value - initial_value == 5
|
||||
|
||||
|
||||
def test_transacting_with_contract_with_string_argument(web3_tester, string_contract):
|
||||
# eth_abi will pass as raw bytes, no encoding
|
||||
# unless we encode ourselves
|
||||
txn_hash = string_contract.transact().setValue(force_bytes("ÄLÄMÖLÖ"))
|
||||
txn_receipt = web3_tester.eth.getTransactionReceipt(txn_hash)
|
||||
assert txn_receipt is not None
|
||||
def test_deploy_when_default_account_is_different_than_coinbase(web3_tester,
|
||||
wait_for_transaction,
|
||||
STRING_CONTRACT):
|
||||
web3_tester.eth.defaultAccount = web3_tester.eth.accounts[1]
|
||||
assert web3_tester.eth.defaultAccount != web3_tester.eth.coinbase
|
||||
|
||||
final_value = string_contract.call().getValue()
|
||||
StringContract = web3_tester.eth.contract(**STRING_CONTRACT)
|
||||
|
||||
assert force_bytes(final_value) == force_bytes("ÄLÄMÖLÖ")
|
||||
deploy_txn = StringContract.deploy(args=["Caqalai"])
|
||||
wait_for_transaction(web3_tester, deploy_txn)
|
||||
txn_after = web3_tester.eth.getTransaction(deploy_txn)
|
||||
assert txn_after['from'] == web3_tester.eth.defaultAccount
|
||||
|
||||
|
||||
def test_transact_when_default_account_is_different_than_coinbase(web3_tester,
|
||||
wait_for_transaction,
|
||||
math_contract):
|
||||
web3_tester.eth.defaultAccount = web3_tester.eth.accounts[1]
|
||||
assert web3_tester.eth.defaultAccount != web3_tester.eth.coinbase
|
||||
|
||||
txn_hash = math_contract.transact().increment()
|
||||
wait_for_transaction(web3_tester, txn_hash)
|
||||
txn_after = web3_tester.eth.getTransaction(txn_hash)
|
||||
assert txn_after['from'] == web3_tester.eth.defaultAccount
|
||||
|
||||
|
||||
def test_transacting_with_contract_with_string_argument(web3_tester, string_contract):
|
||||
|
||||
# eth_abi will pass as raw bytes, no encoding
|
||||
# unless we encode ourselves
|
||||
txn_hash = string_contract.transact().setValue(force_bytes("ÄLÄMÖLÖ"))
|
||||
|
||||
@ -434,7 +434,7 @@ class Contract(object):
|
||||
|
||||
if self.address is not None:
|
||||
transact_transaction.setdefault('to', self.address)
|
||||
transact_transaction.setdefault('from', self.web3.eth.coinbase)
|
||||
transact_transaction.setdefault('from', self.web3.eth.defaultAccount)
|
||||
|
||||
if 'to' not in transact_transaction:
|
||||
if isinstance(self, type):
|
||||
|
||||
Loading…
Reference in New Issue
Block a user