def test_create_ticks(self): end = 4 txs_per_tick = 2 node_0 = NodeConfig('group', 'node-0', 0, 0, None) node_1 = NodeConfig('group', 'node-1', 0, 0, None) nodes = [node_0, node_1] block_events = {'node-0': [0.5, 2.1, end], 'node-1': [0.5, 2.1, end]} event_ticks = ticks_config._create_ticks(nodes, block_events, txs_per_tick, end) self.assertEqual(len(event_ticks), 4) self.assertEqual(len(event_ticks[0]), 4) self.assertEqual(len(event_ticks[1]), 2) self.assertEqual(len(event_ticks[2]), 4) self.assertEqual(len(event_ticks[3]), 2) self.assertTrue('tx ' in event_ticks[0][0]) self.assertTrue('tx ' in event_ticks[1][0]) self.assertTrue('tx ' in event_ticks[2][0]) self.assertTrue('tx ' in event_ticks[3][0]) self.assertTrue('block ' in event_ticks[0][2]) self.assertTrue('block ' in event_ticks[0][3]) self.assertTrue('block ' in event_ticks[2][2]) self.assertTrue('block ' in event_ticks[2][3])
def test_create_ticks(): end = 4 txs_per_tick = 2 node_0 = NodeConfig('group', 'node-0', 0, 0, None) node_1 = NodeConfig('group', 'node-1', 0, 0, None) nodes = [node_0, node_1] block_events = {'node-0': [0.5, 2.1, end], 'node-1': [0.5, 2.1, end]} event_ticks = ticks_config._create_ticks(nodes, block_events, txs_per_tick, end) assert len(event_ticks) == 4 assert len(event_ticks[0]) == 4 assert len(event_ticks[1]) == 2 assert len(event_ticks[2]) == 4 assert len(event_ticks[3]) == 2 assert 'tx ' in event_ticks[0][0] assert 'tx ' in event_ticks[1][0] assert 'tx ' in event_ticks[2][0] assert 'tx ' in event_ticks[3][0] assert 'block ' in event_ticks[0][2] assert 'block ' in event_ticks[0][3] assert 'block ' in event_ticks[2][2] assert 'block ' in event_ticks[2][3]
def test_create_ticks_with_multiple_blocks_in_one_tick(self): end = 4 node_0 = NodeConfig('group', 'node-0', 0, 0, None) block_events = {'node-0': [0.5, 0.6, end]} ticks_config._create_ticks([node_0], block_events, 0, end)