Exemple #1
0
def test_block_broadcast_no_block(fx_session: scoped_session):
    with unittest.mock.patch('nekoyume.tasks.broadcast_block') as m:
        block_broadcast(0,
                        'http://localhost:5000',
                        'http://localhost:5001',
                        session=fx_session)
        assert not m.called
Exemple #2
0
def test_muted_attribute_error(fx_session):
    try:
        block_broadcast(0,
                        'http://localhost:5000',
                        'http://localhsot:5001',
                        session=fx_session)
    except AttributeError:
        pytest.fail('broadcast tasks should not raise AttributeError.')
Exemple #3
0
def test_block_broadcast(fx_session: scoped_session, fx_user: User):
    block = Block.create(fx_user, [])
    fx_session.add(block)
    fx_session.commit()
    with unittest.mock.patch('nekoyume.tasks.broadcast_block') as m:
        block_broadcast(block.id,
                        'http://localhost:5000',
                        'http://localhost:5001',
                        session=fx_session)
        serialized = block.serialize(use_bencode=False,
                                     include_suffix=True,
                                     include_moves=True,
                                     include_hash=True)
        assert m.called
        args = m.call_args[1]
        assert serialized == args['serialized']
        assert isinstance(args['sent_node'], Node)
        assert args['sent_node'].url == 'http://localhost:5000'
        assert isinstance(args['my_node'], Node)
        assert args['my_node'].url == 'http://localhost:5001'