def test_setting_default_and_custom_interests_fails(web3): """Tests that we cannot set default and custom interests at the same time""" with pytest.raises(Exception): settings = { **NETWORK_SETTINGS, "default_interest_rate": 1, "custom_interests": True, } deploy_network(web3, settings)
def test_setting_default_and_custom_interests_fails(web3): """Tests that we cannot set default and custom interests at the same time""" with pytest.raises(eth_tester.exceptions.TransactionFailed): deploy_network( web3, "TestCoin", "T", 6, 0, default_interest_rate=1, custom_interests=True, prevent_mediator_interests=False, )
def currency_network_contract_with_high_trustlines(web3, accounts): contract = deploy_network( web3, name="TestCoin", symbol="T", decimals=6, fee_divisor=100, currency_network_contract_name="TestCurrencyNetwork", expiration_time=EXPIRATION_TIME, ) creditline = 1000000 contract.functions.setAccount(accounts[0], accounts[1], creditline, creditline, 0, 0, False, 0, 0).transact() contract.functions.setAccount(accounts[1], accounts[2], creditline, creditline, 0, 0, False, 0, 0).transact() contract.functions.setAccount(accounts[2], accounts[3], creditline, creditline, 0, 0, False, 0, 0).transact() contract.functions.setAccount(accounts[0], accounts[2], creditline, creditline, 0, 0, False, 0, 0).transact() contract.functions.setAccount(accounts[2], accounts[4], creditline, creditline, 0, 0, False, 0, 0).transact() contract.functions.setAccount(accounts[4], accounts[3], creditline, creditline, 0, 0, False, 0, 0).transact() return contract
def deploy_ownable_network(web3, network_setting, **kwargs): return deploy_network( web3, network_setting, currency_network_contract_name="CurrencyNetworkOwnable", **kwargs, )
def currency_network_contract_with_trustlines(web3, accounts): contract = deploy_network(web3, **NETWORK_SETTING) for (A, B, clAB, clBA) in trustlines: contract.functions.setAccountDefaultInterests(accounts[A], accounts[B], clAB, clBA, False, 0, 0).transact() return contract
def currency_network_contract_with_trustlines(web3, accounts): contract = deploy_network(web3, **NETWORK_SETTING) for (A, B, clAB, clBA) in trustlines: CurrencyNetworkAdapter(contract).set_account( accounts[A], accounts[B], creditline_given=clAB, creditline_received=clBA ) return contract
def deploy_test_network(web3, network_setting, **kwargs): return deploy_network( web3, network_setting, currency_network_contract_name="TestCurrencyNetwork", **kwargs, )
def currency_network_contract_with_trustlines(chain, web3, accounts, interest_rate): currency_network_contract = deploy_network(web3, **NETWORK_SETTING) currency_network_adapter = CurrencyNetworkAdapter( currency_network_contract) current_time = int(time.time()) chain.time_travel(current_time + 10) for a in accounts[:4]: for b in accounts[:4]: if a is b: continue currency_network_adapter.set_account( a, b, creditline_given=1_000_000, creditline_received=1_000_000, interest_rate_given=interest_rate, interest_rate_received=interest_rate, m_time=current_time, ) currency_network_adapter.transfer(10000, path=[accounts[0], accounts[1]]) chain.time_travel(current_time + SECONDS_PER_YEAR) return currency_network_contract
def deploy_test_network(web3): return deploy_network( web3, "Trustlines", "T", 6, fee_divisor=100, expiration_time=EXPIRATION_TIME, currency_network_contract_name="TestCurrencyNetwork", )
def currency_network_contract(web3): return deploy_network( web3, name="Teuro", symbol="TEUR", decimals=2, fee_divisor=100, currency_network_contract_name="TestCurrencyNetwork", expiration_time=EXPIRATION_TIME, )
def deploy_currency_network_v2(web3): return deploy_network( web3, network_settings=NetworkSettings( fee_divisor=100, name="Trustlines", symbol="T", custom_interests=True, expiration_time=EXPIRATION_TIME, ), currency_network_contract_name="CurrencyNetworkV2", )
def test_deploy_network(web3): network = deploy_network(web3, NETWORK_SETTINGS) assert network.functions.name().call() == NETWORK_SETTINGS.name assert network.functions.symbol().call() == NETWORK_SETTINGS.symbol assert network.functions.decimals().call() == NETWORK_SETTINGS.decimals assert (network.functions.customInterests().call() == NETWORK_SETTINGS.custom_interests) assert (network.functions.defaultInterestRate().call() == NETWORK_SETTINGS.default_interest_rate) assert network.functions.expirationTime().call( ) == NETWORK_SETTINGS.expiration_time
def currency_network_contract_authorized_with_trustlines( web3, global_authorized_address, accounts): network_setting = NETWORK_SETTING network_setting["authorized_addresses"] = [global_authorized_address] contract = deploy_network(web3, **NETWORK_SETTING) for (A, B, clAB, clBA) in trustlines: CurrencyNetworkAdapter(contract).set_account(accounts[A], accounts[B], creditline_given=clAB, creditline_received=clBA) return contract
def currency_network_contract_custom_interests_safe_ripple(web3): return deploy_network( web3, "TestCoin", "T", decimals=6, fee_divisor=0, default_interest_rate=0, custom_interests=True, prevent_mediator_interests=True, currency_network_contract_name="TestCurrencyNetwork", expiration_time=EXPIRATION_TIME, )
def currency_network_contract_with_trustlines(web3, accounts): contract = deploy_network( web3, name="TestCoin", symbol="T", decimals=6, fee_divisor=100, currency_network_contract_name="TestCurrencyNetwork", expiration_time=EXPIRATION_TIME, ) for (A, B, clAB, clBA) in trustlines: contract.functions.setAccount(accounts[A], accounts[B], clAB, clBA, 0, 0, False, 0, 0).transact() return contract
def currency_network_contract_with_trustlines(web3, accounts): contract = deploy_network( web3, currency_network_contract_name="TestCurrencyNetwork", name="TestCoin", symbol="T", decimals=6, fee_divisor=100, expiration_time=EXPIRATION_TIME, ) for (A, B, clAB, clBA) in trustlines: CurrencyNetworkAdapter(contract).set_account( accounts[A], accounts[B], creditline_given=clAB, creditline_received=clBA ) return contract
def test_currency_network_v1(web3, currency_network_v2_abi, testnetwork1_address, contracts): """This is the only remaining contract of type `TestCurrencyNetwork`. It should only be used for its test functions of unfreezing a network""" network = deploy_network( web3, network_settings=NetworkSettings( fee_divisor=100, name="Trustlines", symbol="T", custom_interests=True, expiration_time=EXPIRATION_TIME, ), currency_network_contract_name="TestCurrencyNetwork", ) return CurrencyNetworkProxy(web3, contracts["TestCurrencyNetwork"]["abi"], network.address)
def test_deploy_network(web3): network = deploy_network( web3, name="Testcoin", symbol="T", decimals=2, fee_divisor=100, default_interest_rate=100, custom_interests=False, prevent_mediator_interests=False, expiration_time=EXPIRATION_TIME, ) assert network.functions.name().call() == "Testcoin" assert network.functions.symbol().call() == "T" assert network.functions.decimals().call() == 2 assert network.functions.customInterests().call() is False assert network.functions.defaultInterestRate().call() == 100 assert network.functions.expirationTime().call() == EXPIRATION_TIME
def currency_network_v2_contract(web3): return deploy_network( web3, NETWORK_SETTING, currency_network_contract_name="CurrencyNetworkV2", )
def currency_network_contract_default_interests(web3): return deploy_network( web3, attr.evolve(NETWORK_SETTINGS, default_interest_rate=100), currency_network_contract_name="TestCurrencyNetwork", )
def currency_network_contract_negative_interests(web3): return deploy_network( web3, NetworkSettings(default_interest_rate=-100, custom_interests=False), currency_network_contract_name="TestCurrencyNetwork", )
def currency_network_contract_custom_interests_safe_ripple(web3): return deploy_network( web3, NetworkSettings(prevent_mediator_interests=True, custom_interests=True), currency_network_contract_name="TestCurrencyNetwork", )
def currency_network_contract_no_fees(web3): network_setting = NETWORK_SETTING network_setting["fee_divisor"] = 0 return deploy_network(web3, **NETWORK_SETTING)
def currency_network_contract_with_trustline_update(web3, accounts): contract = deploy_network(web3, **NETWORK_SETTING) contract.functions.updateTrustline(accounts[1], 1, 1, 0, 0, False).transact( {"from": accounts[0]} ) return contract
def currency_network_contract_no_interests(web3): return deploy_network( web3, NetworkSettings(custom_interests=False), currency_network_contract_name="TestCurrencyNetwork", )
def currency_network_contract_without_expiration(web3): return deploy_network(web3, **{**NETWORK_SETTING, "expiration_time": 0})
def currency_network_contract(web3): return deploy_network(web3, **NETWORK_SETTING)
def second_currency_network_contract(web3): return deploy_network(web3, NetworkSettings())