Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[OCT-1822] apitest: potential fix for nonce-too-low problem #603

Merged
merged 4 commits into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions backend/app/infrastructure/contracts/erc20.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def glm_fund(self, to_address, nonce):
return self.w3.eth.send_raw_transaction(signed_tx.rawTransaction)

def transfer(self, sender, receiver: str, amount: int):
nonce = self.w3.eth.get_transaction_count(sender.address)
nonce = self.w3.eth.get_transaction_count(sender.address, "pending")
transaction = self.contract.functions.transfer(
receiver, amount
).build_transaction({"from": sender.address, "nonce": nonce})
Expand All @@ -26,7 +26,7 @@ def approve(self, owner, benefactor, wad: int):
print("owner address: ", owner.address)
print("owner key: ", owner.key)
print("benefactor of lock: ", benefactor)
nonce = self.w3.eth.get_transaction_count(owner.address)
nonce = self.w3.eth.get_transaction_count(owner.address, "pending")
transaction = self.contract.functions.approve(
benefactor, wad
).build_transaction({"from": owner.address, "nonce": nonce})
Expand Down
7 changes: 5 additions & 2 deletions backend/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -614,8 +614,11 @@ def snapshot_status(self, epoch):
return json.loads(rv.text), rv.status_code

def pending_snapshot(self):
rv = self._flask_client.post("/snapshots/pending").text
return json.loads(rv)
rv = self._flask_client.post("/snapshots/pending")
current_app.logger.debug(
f"Request to /snapshots/pending [{rv.status_code}] returned text {rv.text}"
paulperegud marked this conversation as resolved.
Show resolved Hide resolved
)
return json.loads(rv.text)

def pending_snapshot_simulate(self):
rv = self._flask_client.get("/snapshots/pending/simulate")
Expand Down
14 changes: 0 additions & 14 deletions backend/v2/glms/contracts.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,6 @@ class AddressKey(Protocol):


class GLMContracts(SmartContract):
# def glm_fund(self, to_address, nonce):
# transaction = self.contract.functions.transfer(
# to_address, app.config["GLM_WITHDRAWAL_AMOUNT"]
# ).build_transaction({"from": app.config["GLM_SENDER_ADDRESS"], "nonce": nonce})
# signed_tx = self.w3.eth.account.sign_transaction(
# transaction, app.config["GLM_SENDER_PRIVATE_KEY"]
# )
# return self.w3.eth.send_raw_transaction(signed_tx.rawTransaction)

# def transfer(self, sender, receiver: str, amount: int):
# async def transfer(self, sender_address: str, receiver: str, amount: int):
async def transfer(
self, sender: AddressKey, receiver_address: str, amount: int
) -> None:
Expand All @@ -42,9 +31,6 @@ async def approve(self, owner: AddressKey, benefactor_address, wad: int):
signed_tx = self.w3.eth.account.sign_transaction(transaction, owner.key)
return self.w3.eth.send_raw_transaction(signed_tx.rawTransaction)

# def balance_of(self, owner: str) -> int:
# return self.contract.functions.balanceOf(owner).call()


ERC20_ABI = [
{
Expand Down
Loading