예제 #1
0
async def test_builder_xdr(setup, helpers, test_data, aio_session):
    hot = Keypair.random()
    hot_account = hot.address().decode()
    hot_secret = hot.seed()

    await helpers.fund_account(setup, hot_account, aio_session)

    cold = Builder(secret=test_data.cold_secret, horizon=test_data.horizon, network_name=setup.network, fee=100) \
        .append_change_trust_op('BEER', test_data.cold_account, '1000', hot_account) \
        .append_allow_trust_op(hot_account, 'BEER', True, test_data.cold_account) \
        .append_payment_op(hot_account, '100', 'BEER', test_data.cold_account, test_data.cold_account) \
        .append_payment_op(test_data.cold_account, '2.222', 'BEER', test_data.cold_account, hot_account)
    await cold.update_sequence()
    cold.sign()

    xdr = cold.gen_xdr()

    hot = Builder(
        secret=hot_secret,
        horizon=test_data.horizon,
        network_name=setup.network, fee=100)
    hot.import_from_xdr(xdr)
    hot.sign()

    assert len(hot.te.signatures) == 2
    assert len(hot.ops) == 4

    response = await hot.submit()
    assert response.get('hash') == hot.hash_hex()
예제 #2
0
def test_builder_xdr(setup, helpers, test_data):
    hot = Keypair.random()
    hot_account = hot.address().decode()
    hot_secret = hot.seed()

    helpers.fund_account(setup, hot_account)

    cold = Builder(secret=test_data.cold_secret, horizon_uri=setup.horizon_endpoint_uri, network=setup.network) \
        .append_change_trust_op('BEER', test_data.cold_account, '1000', hot_account) \
        .append_allow_trust_op(hot_account, 'BEER', True, test_data.cold_account) \
        .append_payment_op(hot_account, '100', 'BEER', test_data.cold_account, test_data.cold_account) \
        .append_payment_op(test_data.cold_account, '2.222', 'BEER', test_data.cold_account, hot_account)
    cold.sign()

    xdr = cold.gen_xdr()

    hot = Builder(secret=hot_secret,
                  horizon_uri=setup.horizon_endpoint_uri,
                  network=setup.network)
    hot.import_from_xdr(xdr)
    hot.sign()

    assert len(hot.te.signatures) == 2
    assert len(hot.ops) == 4

    response = hot.submit()
    assert response.get('hash') == hot.hash_hex()