def test_get_eth2_balances_validator_not_yet_active(beaconchain, inquirer): # pylint: disable=unused-argument # noqa: E501 """Test that if a validator is detected but is not yet active the balance is shown properly Test for: https://github.com/rotki/rotki/issues/1888 """ with _create_beacon_mock(beaconchain): mapping = get_eth2_balances(beaconchain, [ADDR1]) assert len(mapping) == 1 amount = FVal('64.143716247') assert mapping[ADDR1] == Balance(amount=amount, usd_value=amount * FVal('1.5'))
def account_for_staked_eth2_balances( self, addresses: List[ChecksumEthAddress], at_addition: bool = False, ) -> None: if not at_addition: # Before querying the new balances, delete the ones in memory if any self.totals.assets.pop(A_ETH2, None) for _, entry in self.balances.eth.items(): if A_ETH2 in entry.assets: del entry.assets[A_ETH2] mapping = get_eth2_balances(self.beaconchain, addresses) for address, balance in mapping.items(): self.balances.eth[address].assets[A_ETH2] = balance self.totals.assets[A_ETH2] += balance
def account_for_staked_eth2_balances( self, addresses: List[ChecksumEthAddress], at_addition: bool = False, ) -> None: if not at_addition: # Before querying the new balances, delete the ones in memory if any self.totals.assets.pop(A_ETH2, None) for _, entry in self.balances.eth.items(): if A_ETH2 in entry.assets: del entry.assets[A_ETH2] try: mapping = get_eth2_balances(self.beaconchain, addresses) except RemoteError as e: self.msg_aggregator.add_error( f'Did not manage to query beaconcha.in api for addresses due to {str(e)}.' f' If you have Eth2 staked balances the final balance results may not be accurate', ) mapping = {} for address, balance in mapping.items(): self.balances.eth[address].assets[A_ETH2] = balance self.totals.assets[A_ETH2] += balance