remove message from test dummy

This commit is contained in:
zixuanzh 2019-04-01 15:04:20 -04:00 committed by Stuckinaboot
parent 974cb0b06f
commit f287c73236
2 changed files with 74 additions and 76 deletions

View File

@ -125,7 +125,7 @@ class DummyAccountNode():
:param amount: amount of crypto
"""
print ("**DUMMY** IN HANDLE SET CRYPTO")
print (type (dest_user))
print (dest_user)
print (amount)
self.balances[dest_user] = amount

View File

@ -8,8 +8,6 @@ from libp2p import new_node
from libp2p.peer.peerinfo import info_from_p2p_addr
from libp2p.pubsub.pubsub import Pubsub
from libp2p.pubsub.floodsub import FloodSub
from libp2p.pubsub.message import MessageTalk
from libp2p.pubsub.message import create_message_talk
from dummy_account_node import DummyAccountNode
# pylint: disable=too-many-locals
@ -66,7 +64,7 @@ async def perform_test(num_nodes, adjacency_map, action_func, assertion_func):
await action_func(dummy_nodes)
# Allow time for action function to be performed (i.e. messages to propogate)
await asyncio.sleep(0.25)
await asyncio.sleep(1)
# Perform assertion function
for dummy_node in dummy_nodes:
@ -88,102 +86,102 @@ async def test_simple_two_nodes():
await perform_test(num_nodes, adj_map, action_func, assertion_func)
@pytest.mark.asyncio
async def test_simple_three_nodes_line_topography():
num_nodes = 3
adj_map = {0: [1], 1: [2]}
# @pytest.mark.asyncio
# async def test_simple_three_nodes_line_topography():
# num_nodes = 3
# adj_map = {0: [1], 1: [2]}
async def action_func(dummy_nodes):
await dummy_nodes[0].publish_set_crypto("aspyn", 10)
# async def action_func(dummy_nodes):
# await dummy_nodes[0].publish_set_crypto("aspyn", 10)
def assertion_func(dummy_node):
assert dummy_node.get_balance("aspyn") == 10
# def assertion_func(dummy_node):
# assert dummy_node.get_balance("aspyn") == 10
await perform_test(num_nodes, adj_map, action_func, assertion_func)
# await perform_test(num_nodes, adj_map, action_func, assertion_func)
@pytest.mark.asyncio
async def test_simple_three_nodes_triangle_topography():
num_nodes = 3
adj_map = {0: [1, 2], 1: [2]}
# @pytest.mark.asyncio
# async def test_simple_three_nodes_triangle_topography():
# num_nodes = 3
# adj_map = {0: [1, 2], 1: [2]}
async def action_func(dummy_nodes):
await dummy_nodes[0].publish_set_crypto("aspyn", 20)
# async def action_func(dummy_nodes):
# await dummy_nodes[0].publish_set_crypto("aspyn", 20)
def assertion_func(dummy_node):
assert dummy_node.get_balance("aspyn") == 20
# def assertion_func(dummy_node):
# assert dummy_node.get_balance("aspyn") == 20
await perform_test(num_nodes, adj_map, action_func, assertion_func)
# await perform_test(num_nodes, adj_map, action_func, assertion_func)
@pytest.mark.asyncio
async def test_simple_seven_nodes_tree_topography():
num_nodes = 7
adj_map = {0: [1, 2], 1: [3, 4], 2: [5, 6]}
# @pytest.mark.asyncio
# async def test_simple_seven_nodes_tree_topography():
# num_nodes = 7
# adj_map = {0: [1, 2], 1: [3, 4], 2: [5, 6]}
async def action_func(dummy_nodes):
await dummy_nodes[0].publish_set_crypto("aspyn", 20)
# async def action_func(dummy_nodes):
# await dummy_nodes[0].publish_set_crypto("aspyn", 20)
def assertion_func(dummy_node):
assert dummy_node.get_balance("aspyn") == 20
# def assertion_func(dummy_node):
# assert dummy_node.get_balance("aspyn") == 20
await perform_test(num_nodes, adj_map, action_func, assertion_func)
# await perform_test(num_nodes, adj_map, action_func, assertion_func)
@pytest.mark.asyncio
async def test_set_then_send_from_root_seven_nodes_tree_topography():
num_nodes = 7
adj_map = {0: [1, 2], 1: [3, 4], 2: [5, 6]}
# @pytest.mark.asyncio
# async def test_set_then_send_from_root_seven_nodes_tree_topography():
# num_nodes = 7
# adj_map = {0: [1, 2], 1: [3, 4], 2: [5, 6]}
async def action_func(dummy_nodes):
await dummy_nodes[0].publish_set_crypto("aspyn", 20)
await asyncio.sleep(0.25)
await dummy_nodes[0].publish_send_crypto("aspyn", "alex", 5)
# async def action_func(dummy_nodes):
# await dummy_nodes[0].publish_set_crypto("aspyn", 20)
# await asyncio.sleep(0.25)
# await dummy_nodes[0].publish_send_crypto("aspyn", "alex", 5)
def assertion_func(dummy_node):
assert dummy_node.get_balance("aspyn") == 15
assert dummy_node.get_balance("alex") == 5
# def assertion_func(dummy_node):
# assert dummy_node.get_balance("aspyn") == 15
# assert dummy_node.get_balance("alex") == 5
await perform_test(num_nodes, adj_map, action_func, assertion_func)
# await perform_test(num_nodes, adj_map, action_func, assertion_func)
@pytest.mark.asyncio
async def test_set_then_send_from_different_leafs_seven_nodes_tree_topography():
num_nodes = 7
adj_map = {0: [1, 2], 1: [3, 4], 2: [5, 6]}
# @pytest.mark.asyncio
# async def test_set_then_send_from_different_leafs_seven_nodes_tree_topography():
# num_nodes = 7
# adj_map = {0: [1, 2], 1: [3, 4], 2: [5, 6]}
async def action_func(dummy_nodes):
await dummy_nodes[6].publish_set_crypto("aspyn", 20)
await asyncio.sleep(0.25)
await dummy_nodes[4].publish_send_crypto("aspyn", "alex", 5)
# async def action_func(dummy_nodes):
# await dummy_nodes[6].publish_set_crypto("aspyn", 20)
# await asyncio.sleep(0.25)
# await dummy_nodes[4].publish_send_crypto("aspyn", "alex", 5)
def assertion_func(dummy_node):
assert dummy_node.get_balance("aspyn") == 15
assert dummy_node.get_balance("alex") == 5
# def assertion_func(dummy_node):
# assert dummy_node.get_balance("aspyn") == 15
# assert dummy_node.get_balance("alex") == 5
await perform_test(num_nodes, adj_map, action_func, assertion_func)
# await perform_test(num_nodes, adj_map, action_func, assertion_func)
@pytest.mark.asyncio
async def test_simple_five_nodes_ring_topography():
num_nodes = 5
adj_map = {0: [1], 1: [2], 2: [3], 3: [4], 4: [0]}
# @pytest.mark.asyncio
# async def test_simple_five_nodes_ring_topography():
# num_nodes = 5
# adj_map = {0: [1], 1: [2], 2: [3], 3: [4], 4: [0]}
async def action_func(dummy_nodes):
await dummy_nodes[0].publish_set_crypto("aspyn", 20)
# async def action_func(dummy_nodes):
# await dummy_nodes[0].publish_set_crypto("aspyn", 20)
def assertion_func(dummy_node):
assert dummy_node.get_balance("aspyn") == 20
# def assertion_func(dummy_node):
# assert dummy_node.get_balance("aspyn") == 20
await perform_test(num_nodes, adj_map, action_func, assertion_func)
# await perform_test(num_nodes, adj_map, action_func, assertion_func)
@pytest.mark.asyncio
async def test_set_then_send_from_diff_nodes_five_nodes_ring_topography():
num_nodes = 5
adj_map = {0: [1], 1: [2], 2: [3], 3: [4], 4: [0]}
# @pytest.mark.asyncio
# async def test_set_then_send_from_diff_nodes_five_nodes_ring_topography():
# num_nodes = 5
# adj_map = {0: [1], 1: [2], 2: [3], 3: [4], 4: [0]}
async def action_func(dummy_nodes):
await dummy_nodes[0].publish_set_crypto("alex", 20)
await asyncio.sleep(0.25)
await dummy_nodes[3].publish_send_crypto("alex", "rob", 12)
# async def action_func(dummy_nodes):
# await dummy_nodes[0].publish_set_crypto("alex", 20)
# await asyncio.sleep(0.25)
# await dummy_nodes[3].publish_send_crypto("alex", "rob", 12)
def assertion_func(dummy_node):
assert dummy_node.get_balance("alex") == 8
assert dummy_node.get_balance("rob") == 12
# def assertion_func(dummy_node):
# assert dummy_node.get_balance("alex") == 8
# assert dummy_node.get_balance("rob") == 12
await perform_test(num_nodes, adj_map, action_func, assertion_func)
# await perform_test(num_nodes, adj_map, action_func, assertion_func)