diff --git a/test/functional/feature_staking_unlock_and_withdraw.py b/test/functional/feature_staking_unlock_and_withdraw.py index c467002..7edff73 100755 --- a/test/functional/feature_staking_unlock_and_withdraw.py +++ b/test/functional/feature_staking_unlock_and_withdraw.py @@ -65,6 +65,7 @@ def run_test(self): assert_equal(len(ledger[0][1]['unlocking']),0) alice_stash = Keypair.create_from_uri('//Alice//stash') + alice = Keypair.create_from_uri('//Alice') # fetch the genesis utxo from storage utxos = list(client.utxos_for(alice_stash)) @@ -87,9 +88,17 @@ def run_test(self): assert_equal(events[2].value['event_id'], 'StakeUnlocked') ledger = list(client.get_staking_ledger()) + assert_equal(len(ledger),2) - time.sleep(500) + time_elapsed = 0 + max_wait = 1200 + time_step = 1 + while client.current_era() < client.withdrawal_era(alice): + if time_elapsed > max_wait: + raise Exception('Timeout: waited too long for withdrawal_era') + time.sleep(time_step) + time_elapsed +=time_step (_, _, w_events) = client.withdraw_stake(alice_stash) diff --git a/test/functional/test_framework/mintlayer/staking.py b/test/functional/test_framework/mintlayer/staking.py index 722e9ac..cdfec7a 100644 --- a/test/functional/test_framework/mintlayer/staking.py +++ b/test/functional/test_framework/mintlayer/staking.py @@ -20,7 +20,10 @@ def current_era(self): module='Staking', storage_function='CurrentEra' ) - return query + # this query returns an object of type scalecodec.types.U32 + # so we convert it to an integer + # TODO find a more elegant way to do conversion + return int("{}".format(query)) """ gets the staking ledger of the given key """ def get_ledger(self, keypair): diff --git a/test/functional/test_runner.py b/test/functional/test_runner.py index ad07c29..635b752 100755 --- a/test/functional/test_runner.py +++ b/test/functional/test_runner.py @@ -66,7 +66,7 @@ 'feature_staking_withdraw_no_unlock.py', 'feature_staking_withdraw_not_validator.py', 'feature_smart_contract_test.py', -# 'feature_staking_unlock_and_withdraw.py' ## should be ran on 20 secs + 'feature_staking_unlock_and_withdraw.py' ## should be ran on 20 secs # Don't append tests at the end to avoid merge conflicts # Put them in a random line within the section that fits their approximate run-time ]