Ejemplo n.º 1
0
    def test_stubborn_private_lead_behind_trail_stubborn(self):
        strategy = Strategy(trail_stubborn=-2)

        with self.assertRaisesRegexp(
                ActionException,
                "private_lead.*should not be behind trail_stubborn.*"):
            strategy.find_action(1, 3, BlockOrigin.private)
Ejemplo n.º 2
0
def main():
    args = parse_args()

    config_logger(args.verbose)

    logging.info("arguments called with: {}".format(sys.argv))
    logging.info("parsed arguments: {}".format(args))

    sync = Sync()

    networking = Networking(args.check_blocks_in_flight_interval, args.private_ip, sync)
    executor = Executor(networking)
    strategy = Strategy(args.lead_stubborn, args.equal_fork_stubborn, args.trail_stubborn)
    if args.start_hash:
        chain = Chain(executor, strategy, core.lx(args.start_hash))
    else:
        chain = Chain(executor, strategy)
    networking.chain = chain

    t = threading.Thread(target=cliserver.start, args=(chain, sync,))
    t.daemon = True
    t.start()

    networking.start()
Ejemplo n.º 3
0
    def test_private_lead1_block_origin_public(self):
        strategy = Strategy()

        action = strategy.find_action(1, 1, BlockOrigin.public)
        self.assertEqual(action, Action.match)
        self.assertEqual(strategy.active, True)
Ejemplo n.º 4
0
    def test_same_length_block_origin_public(self):
        strategy = Strategy()

        action = strategy.find_action(0, 1, BlockOrigin.public)
        self.assertEqual(action, Action.adopt)
Ejemplo n.º 5
0
    def test_match_block_both_chain_same_length_trail_stubborn_not_active_origin_public(
            self):
        strategy = Strategy(trail_stubborn=1)

        action = strategy.find_action(2, 3, BlockOrigin.public)
        self.assertEqual(action, Action.wait)
Ejemplo n.º 6
0
    def test_match_block_both_chain_same_length_trail_stubborn_not_active_origin_private(
            self):
        strategy = Strategy(trail_stubborn=1)

        action = strategy.find_action(3, 2, BlockOrigin.private)
        self.assertEqual(action, Action.override)
Ejemplo n.º 7
0
    def test_match_stubborn_block_origin_private(self):
        strategy = Strategy(equal_fork_stubborn=True)
        strategy.active = True

        action = strategy.find_action(1, 0, BlockOrigin.private)
        self.assertEqual(action, Action.wait)
Ejemplo n.º 8
0
    def test_match_block_both_chain_same_length_not_active_origin_public(self):
        strategy = Strategy()

        action = strategy.find_action(2, 3, BlockOrigin.public)
        self.assertEqual(action, Action.adopt)
Ejemplo n.º 9
0
    def test_high_private_lead_block_origin_public(self):
        strategy = Strategy()

        action = strategy.find_action(3, 1, BlockOrigin.public)
        self.assertEqual(action, Action.wait)
Ejemplo n.º 10
0
    def test_match_stubborn_block_origin_public(self):
        strategy = Strategy(equal_fork_stubborn=True)
        strategy.active = True

        action = strategy.find_action(0, 1, BlockOrigin.public)
        self.assertEqual(action, Action.adopt)
Ejemplo n.º 11
0
    def test_stubborn_catch_up2(self):
        strategy = Strategy()

        action = strategy.find_action(3, 2, BlockOrigin.private)
        self.assertEqual(action, Action.override)
Ejemplo n.º 12
0
    def test_private_lead2_block_origin_public(self):
        strategy = Strategy()

        action = strategy.find_action(2, 1, BlockOrigin.public)
        self.assertEqual(action, Action.override)
Ejemplo n.º 13
0
    def test_stubborn2_public_lead2_block_origin_public(self):
        strategy = Strategy(trail_stubborn=2)

        action = strategy.find_action(0, 3, BlockOrigin.public)
        self.assertEqual(action, Action.adopt)
Ejemplo n.º 14
0
    def test_stubborn2_public_lead2_block_origin_private(self):
        strategy = Strategy(trail_stubborn=2)

        action = strategy.find_action(1, 2, BlockOrigin.private)
        self.assertEqual(action, Action.wait)
Ejemplo n.º 15
0
    def test_stubborn_high_private_lead_block_origin_private(self):
        strategy = Strategy(lead_stubborn=True)

        action = strategy.find_action(4, 0, BlockOrigin.private)
        self.assertEqual(action, Action.wait)
Ejemplo n.º 16
0
    def test_stubborn_high_private_lead_block_origin_public(self):
        strategy = Strategy(lead_stubborn=True)

        action = strategy.find_action(3, 1, BlockOrigin.public)
        self.assertEqual(action, Action.match)
        self.assertEqual(strategy.active, True)
Ejemplo n.º 17
0
    def test_public_lead1_block_origin_public(self):
        strategy = Strategy()

        action = strategy.find_action(0, 2, BlockOrigin.public)
        self.assertEqual(action, Action.adopt)
Ejemplo n.º 18
0
    def test_private_lead2_block_origin_private(self):
        strategy = Strategy()

        action = strategy.find_action(3, 0, BlockOrigin.private)
        self.assertEqual(action, Action.wait)
Ejemplo n.º 19
0
    def test_match_block_origin_private(self):
        strategy = Strategy()
        strategy.active = True

        action = strategy.find_action(2, 1, BlockOrigin.private)
        self.assertEqual(action, Action.override)