Skip to content

Commit

Permalink
Fix failing staking escrow additional test.
Browse files Browse the repository at this point in the history
Code cleanup.

Co-authored-by: vzotova <[email protected]>
  • Loading branch information
derekpierre and vzotova committed Feb 2, 2024
1 parent 1ea7fa5 commit 6fb1570
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 18 deletions.
38 changes: 24 additions & 14 deletions tests/staking_escrow/test_staking_escrow_additional.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,15 @@ def test_upgrading(accounts, token, t_token, vending_machine, project):
dispatcher = creator.deploy(project.Dispatcher, contract_library_v1.address)

tx = creator.history[-1]
assert tx.events == [
dispatcher.OwnershipTransferred(previousOwner=ZERO_ADDRESS, newOwner=creator),
dispatcher.StateVerified(testTarget=contract_library_v1.address, sender=creator),
dispatcher.UpgradeFinished(target=contract_library_v1.address, sender=creator),
]
assert tx.events[0] == dispatcher.OwnershipTransferred(
previousOwner=ZERO_ADDRESS, newOwner=creator
)
assert tx.events[1] == dispatcher.StateVerified(
testTarget=contract_library_v1.address, sender=creator
)
assert tx.events[2] == dispatcher.UpgradeFinished(
target=contract_library_v1.address, sender=creator
)

# Deploy second version of the contract
contract_library_v2 = creator.deploy(
Expand Down Expand Up @@ -82,11 +86,15 @@ def test_upgrading(accounts, token, t_token, vending_machine, project):
contract.setValueToCheck(3, sender=creator)
assert contract.valueToCheck() == 3

assert tx.events == [
dispatcher.StateVerified(testTarget=contract_library_v2.address, sender=creator),
dispatcher.StateVerified(testTarget=contract_library_v2.address, sender=creator),
dispatcher.UpgradeFinished(target=contract_library_v2.address, sender=creator),
]
assert tx.events[0] == dispatcher.StateVerified(
testTarget=contract_library_v2.address, sender=creator
)
assert tx.events[1] == dispatcher.StateVerified(
testTarget=contract_library_v2.address, sender=creator
)
assert tx.events[2] == dispatcher.UpgradeFinished(
target=contract_library_v2.address, sender=creator
)

# Can't upgrade to the previous version or to the bad version
contract_library_bad = creator.deploy(
Expand Down Expand Up @@ -124,10 +132,12 @@ def test_upgrading(accounts, token, t_token, vending_machine, project):
assert contract_library_v1.address == event["target"]
assert event["sender"] == creator

assert tx.events == [
dispatcher.StateVerified(testTarget=contract_library_v2.address, sender=creator),
dispatcher.UpgradeFinished(target=contract_library_v1.address, sender=creator),
]
assert tx.events[1] == dispatcher.StateVerified(
testTarget=contract_library_v2.address, sender=creator
)
assert tx.events[2] == dispatcher.UpgradeFinished(
target=contract_library_v1.address, sender=creator
)


def test_measure_work(accounts, token, worklock, escrow):
Expand Down
4 changes: 2 additions & 2 deletions tests/test_beta_program_initiator.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def test_register(accounts, beta_program_initiator, token, coordinator):
event = events[0]
assert event.sender == initiator_1
assert event.requestIndex == 0
assert event.providers == list(n.address for n in nodes)
assert event.providers == [n.address for n in nodes]
assert event.authority == authority
assert event.duration == duration
assert event.accessController == access_controller
Expand Down Expand Up @@ -142,7 +142,7 @@ def test_register(accounts, beta_program_initiator, token, coordinator):
event = events[0]
assert event.sender == initiator_2
assert event.requestIndex == 1
assert event.providers == list(n.address for n in nodes)
assert event.providers == [n.address for n in nodes]
assert event.authority == authority
assert event.duration == duration
assert event.accessController == access_controller
Expand Down
5 changes: 3 additions & 2 deletions tests/test_coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import pytest
from eth_account import Account
from eth_account.messages import encode_defunct
from hexbytes import HexBytes
from web3 import Web3

TIMEOUT = 1000
Expand Down Expand Up @@ -190,7 +191,7 @@ def test_initiate_ritual(
event = events[0]
assert event.ritualId == ritualID
assert event.authority == authority
assert event.participants == list(n.address for n in nodes)
assert event.participants == [n.address for n in nodes]

assert coordinator.getRitualState(0) == RitualState.DKG_AWAITING_TRANSCRIPTS

Expand Down Expand Up @@ -236,7 +237,7 @@ def test_provider_public_key(coordinator, nodes):
event = events[0]
assert event.ritualId == ritual_id
assert event.participant == selected_provider
assert tuple(event.publicKey) == public_key
assert event.publicKey == [HexBytes(k) for k in public_key]
assert coordinator.getProviderPublicKey(selected_provider, ritual_id) == public_key


Expand Down

0 comments on commit 6fb1570

Please sign in to comment.