def test_contract_epoch_fetcher_udpates_last_fetch_height( w3, tester, validator_set_contract): val_def, (contract, ) = initialize_scenario(validator_set_contract, transition_heights=[100]) fetcher = ContractEpochFetcher(w3, val_def[0], 0) mine_until(w3, tester, 123) fetcher.fetch_new_epochs() assert fetcher.last_fetch_height == 123
def test_fetch_first_epoch(w3, validator_set_contract): val_def, (contract, ) = initialize_scenario(validator_set_contract, transition_heights=[100]) validators = initialize_validators(contract) fetcher = ContractEpochFetcher(w3, val_def[0], 0) epochs = fetcher.fetch_new_epochs() assert epochs == [Epoch(100, validators, 0)]
def test_fetch_second_time(w3, validator_set_contract): val_def, (contract, ) = initialize_scenario(validator_set_contract, transition_heights=[100]) initialize_validators(contract) fetcher = ContractEpochFetcher(w3, val_def[0], 0) fetcher.fetch_new_epochs() epochs = fetcher.fetch_new_epochs() assert epochs == []
def test_fetch_single_update(w3, tester, validator_set_contract): val_def, (contract, ) = initialize_scenario(validator_set_contract, transition_heights=[100]) initialize_validators(contract) fetcher = ContractEpochFetcher(w3, val_def[0], 0) fetcher.fetch_new_epochs() mine_until(w3, tester, 105) validators, height = change_validators(contract) epochs = fetcher.fetch_new_epochs() assert epochs == [Epoch(height, validators, 0)]
def test_contract_epoch_fetcher_initialization(w3, validator_set_contract): val_def, (contract, ) = initialize_scenario(validator_set_contract, transition_heights=[100]) fetcher = ContractEpochFetcher(w3, val_def[0], 0) assert fetcher.earliest_fetched_epoch is None assert fetcher.latest_fetched_epoch is None assert fetcher.last_fetch_height is None
def test_fetch_multiple_updates(w3, tester, validator_set_contract): val_def, (contract, ) = initialize_scenario(validator_set_contract, transition_heights=[100]) initialize_validators(contract) fetcher = ContractEpochFetcher(w3, val_def[0], 0) fetcher.fetch_new_epochs() mine_until(w3, tester, 105) validators1, height1 = change_validators(contract) mine_until(w3, tester, height1 + 10) validators2, height2 = change_validators(contract) epochs = fetcher.fetch_new_epochs() assert epochs == [ Epoch(height1, validators1, 0), Epoch(height2, validators2, 0) ]
def test_contract_epoch_fetcher_sets_latest_epoch(w3, tester, validator_set_contract): val_def, (contract, ) = initialize_scenario(validator_set_contract, transition_heights=[100]) validators1 = initialize_validators(contract) fetcher = ContractEpochFetcher(w3, val_def[0], 0) fetcher.fetch_new_epochs() assert fetcher.latest_fetched_epoch == Epoch(100, validators1, 0) mine_until(w3, tester, 105) validators2, height2 = change_validators(contract) fetcher.fetch_new_epochs() assert fetcher.latest_fetched_epoch == Epoch(height2, validators2, 0)