def test_create_account_nonexistent_asset(): '''Test that we can't create an account for an asset that doesn't exist''' fake_id = Nym().create()._id # just to get a plausible asset id fake_asset = Asset(_id=fake_id, server_id=server.first_active_id()) acct = account.Account(fake_asset, Nym().register()) with error.expected(ReturnValueError): acct.create()
def test_create_account(): server_id = server.first_id() nym = Nym().register(server_id) asset = Asset().issue(nym, open(data.btc_contract_file), server_id) myacct = account.Account(asset, nym).create() accounts = account.get_all_ids() assert myacct._id in accounts
def test_issue_asset_contract(issue_for_other_nym, expect_success): server_id = server.first_id() nym = Nym().register(server_id) issue_for_nym = Nym().register(server_id) if issue_for_other_nym else nym with error.expected(None if expect_success else ReturnValueError): Asset().issue(nym, open(data.btc_contract_file), server_id, issue_for_nym=issue_for_nym)
def an_account(): '''Generates a test account (non-issuer)''' nym = Nym().register() asset = Asset().issue(nym, open(data.btc_contract_file)) return account.Account(asset, Nym().register())
def test_two_assets_same_nym_and_contract(): '''Should be able to create two asset types with the same contract''' nym = Nym().register() asset1 = Asset().issue(nym, open(data.btc_contract_file)) asset2 = Asset().issue(nym, open(data.btc_contract_file)) assert asset1._id != asset2._id
def test_asset_count_increments(): then = opentxs.OTAPI_Wrap_GetAssetTypeCount() Asset().issue(Nym().register(), open(data.btc_contract_file)) now = opentxs.OTAPI_Wrap_GetAssetTypeCount() assert then + 1 == now
def test_asset_nym_not_registered(): with error.expected(ReturnValueError): Asset().issue(Nym().create(), open(data.btc_contract_file))
def test_account_nym_not_registered(): nym = Nym().register() asset = Asset().issue(nym, open(data.btc_contract_file)) with error.expected(ReturnValueError): account.Account(asset, Nym().create()).create()
def an_asset(): return Asset().issue(Nym().register(), open(data.btc_contract_file))
def __init__(self): self.asset = Asset().issue(Nym().register(), open(btc_contract_file)) self.source = account.Account(self.asset, Nym().register()).create() self.target = account.Account(self.asset, Nym().register()).create() self.issuer = self.asset.issuer_account