shohu / c0ban

c0ban source tree
MIT License
0 stars 0 forks source link

Pass for test invalidblockrequest.py #26

Closed shohu closed 6 years ago

shohu commented 6 years ago

Output

# test/functional/invalidblockrequest.py
2018-03-23 01:17:52.112000 TestFramework (INFO): Initializing test directory /tmp/testww_n4h7q
2018-03-23 01:17:52.397000 TestFramework.mininode (INFO): Connecting to Bitcoin Node: 127.0.0.1:11176
2018-03-23 01:17:52.656000 TestFramework.comptool (INFO): Test 1: PASS
2018-03-23 01:17:53.130000 TestFramework.comptool (INFO): Test 2: PASS
2018-03-23 01:17:53.447000 TestFramework.comptool (INFO): Test 3: PASS
2018-03-23 01:17:53.552000 TestFramework.comptool (ERROR): Block not in reject map: 51b9c9777221201f9780e462fa35f038fac5cb9a5108777ddfb260bead379194
2018-03-23 01:17:53.552000 TestFramework (ERROR): Assertion failed
Traceback (most recent call last):
  File "/c0ban/test/functional/test_framework/test_framework.py", line 120, in main
    self.run_test()
  File "test/functional/invalidblockrequest.py", line 36, in run_test
    test.run()
  File "/c0ban/test/functional/test_framework/comptool.py", line 354, in run
    raise AssertionError("Test failed at test %d" % test_number)
AssertionError: Test failed at test 4
2018-03-23 01:17:53.570000 TestFramework (INFO): Stopping nodes
2018-03-23 01:17:55.674000 TestFramework (WARNING): Not cleaning up dir /tmp/testww_n4h7q
2018-03-23 01:17:55.674000 TestFramework (ERROR): Test failed. Test logging available at /tmp/testww_n4h7q/test_framework.log
shohu commented 6 years ago

testcode

        '''
        Make sure that a totally screwed up block is not valid.
        '''
        block3 = create_block(self.tip, create_coinbase(height), self.block_time)
        self.block_time += 1
        block3.vtx[0].vout[0].nValue = 100 * COIN # Too high!
        block3.vtx[0].sha256=None
        block3.vtx[0].calc_sha256()
        block3.hashMerkleRoot = block3.calc_merkle_root()
        block3.rehash()
        block3.solve()

        yield TestInstance([[block3, RejectResult(16, b'bad-cb-amount')]])  ## Error was occured !!!
shohu commented 6 years ago

Focus on "bad-cb-amount"

Originally "bad-cb-amount" should be occured, but it has not occurred

c0band

    int64_t nTime3 = GetTimeMicros(); nTimeConnect += nTime3 - nTime2;
    LogPrint(BCLog::BENCH, "      - Connect %u transactions: %.2fms (%.3fms/tx, %.3fms/txin) [%.2fs]\n", (unsigned)block.vtx.size(), 0.001 * (nTime3 - nTime2), 0.001 * (nTime3 - nTime2) / block.vtx.size(), nInputs <= 1 ? 0 : 0.001 * (nTime3 - nTime2) / (nInputs-1), nTimeConnect * 0.000001);

    CAmount blockReward = nFees + GetBlockSubsidy(pindex->nHeight, chainparams.GetConsensus());
    if (block.vtx[0]->GetValueOut() > blockReward)
        return state.DoS(100,
                         error("ConnectBlock(): coinbase pays too much (actual=%d vs limit=%d)",
                               block.vtx[0]->GetValueOut(), blockReward),
                               REJECT_INVALID, "bad-cb-amount");

GetBlockSubsidy ... Wrote log to source.

    CAmount blockReward = nFees + GetBlockSubsidy(pindex->nHeight, chainparams.GetConsensus());
    LogPrint(BCLog::BENCH, "!!!!! GetValueOut = %d,blockReward = %d \n", block.vtx[0]->GetValueOut(), blockReward);
    if (block.vtx[0]->GetValueOut() > blockReward)
        return state.DoS(100,
                         error("ConnectBlock(): coinbase pays too much (actual=%d vs limit=%d)",
                               block.vtx[0]->GetValueOut(), blockReward),
                               REJECT_INVALID, "bad-cb-amount");
2018-03-27 06:26:18.911612 !!!!! GetValueOut = 10000000000,blockReward = 2200000000000

I passed test when changed source below. ( follwing "221" means 2200000000000 / 10000000000 + 1 ) 2018-03-27 15 35 00

output

# test/functional/invalidblockrequest.py
2018-03-27 06:33:59.478000 TestFramework (INFO): Initializing test directory /tmp/test85zoo2le
2018-03-27 06:33:59.748000 TestFramework.mininode (INFO): Connecting to Bitcoin Node: 127.0.0.1:12839
2018-03-27 06:34:00.009000 TestFramework.comptool (INFO): Test 1: PASS
2018-03-27 06:34:00.445000 TestFramework.comptool (INFO): Test 2: PASS
2018-03-27 06:34:00.710000 TestFramework.comptool (INFO): Test 3: PASS
2018-03-27 06:34:00.814000 TestFramework.comptool (INFO): Test 4: PASS
2018-03-27 06:34:00.917000 TestFramework (INFO): Stopping nodes
2018-03-27 06:34:03.101000 TestFramework (INFO): Cleaning up
2018-03-27 06:34:03.104000 TestFramework (INFO): Tests successful
shohu commented 6 years ago

I fixed "block generating speed", but I got following error.

# test/functional/invalidblockrequest.py
2018-04-03 09:21:24.154000 TestFramework (INFO): Initializing test directory /tmp/testenc2xcjv
2018-04-03 09:21:24.419000 TestFramework.mininode (INFO): Connecting to Bitcoin Node: 127.0.0.1:13982
2018-04-03 09:21:24.681000 TestFramework.comptool (INFO): Test 1: PASS
2018-04-03 09:21:25.058000 TestFramework.comptool (INFO): Test 2: PASS
2018-04-03 09:22:25.080000 TestFramework (ERROR): Assertion failed
Traceback (most recent call last):
  File "/c0ban/test/functional/test_framework/test_framework.py", line 120, in main
    self.run_test()
  File "test/functional/invalidblockrequest.py", line 38, in run_test
    test.run()
  File "/c0ban/test/functional/test_framework/comptool.py", line 352, in run
    self.wait_for_pings(self.ping_counter)
  File "/c0ban/test/functional/test_framework/comptool.py", line 201, in wait_for_pings
    wait_until(received_pongs, lock=mininode_lock)
  File "/c0ban/test/functional/test_framework/util.py", line 222, in wait_until
    assert_greater_than(timeout, time.time())
  File "/c0ban/test/functional/test_framework/util.py", line 42, in assert_greater_than
    raise AssertionError("%s <= %s" % (str(thing1), str(thing2)))
AssertionError: 1522747345.0611234 <= 1522747345.079991
2018-04-03 09:22:25.118000 TestFramework (INFO): Stopping nodes
2018-04-03 09:22:27.245000 TestFramework (WARNING): Not cleaning up dir /tmp/testenc2xcjv
2018-04-03 09:22:27.246000 TestFramework (ERROR): Test failed. Test logging available at /tmp/testenc2xcjv/test_framework.log
shohu commented 6 years ago

Stop following source

yield TestInstance([[block2, RejectResult(16, b'bad-txns-duplicate')], [block2_orig, True]])
shohu commented 6 years ago

I delete pdb source, so I got pass the test