[monero-project/monero] Regtest (#3854)

moneromooo-monero commented on this pull request.

> @@ -419,6 +420,10 @@ bool Blockchain::init(BlockchainDB* db, const network_type nettype, bool offline
// ensure we fixup anything we found and fix in the future
m_db->fixup();
}
+ else if (m_regtest)
+ {
+ m_db->set_batch_transactions(true);
+ }

Why is this here ?

> +
+ template_req.reserve_size = 1;
+ template_req.wallet_address = req.wallet_address;
+ submit_req.push_back(boost::value_initialized());
+
+ for(size_t i = 0; i < req.amount_of_blocks; i++) + { + + if(!on_getblocktemplate(template_req, template_res, error_resp)) return false; + + submit_req.front() = template_res.blocktemplate_blob; + if(!on_submitblock(submit_req, submit_res, error_resp)) return false; + + res.height = template_res.height; + res.status = submit_res.status; + } if req.amount_of_blocks is 0, res.status is uninitialized. The interetsing case where you might want to carry it over is when a RPC returns false anyway, not true. > @@ -129,6 +129,7 @@ namespace cryptonote
MAP_JON_RPC_WE(«getblocktemplate», on_getblocktemplate, COMMAND_RPC_GETBLOCKTEMPLATE)
MAP_JON_RPC_WE(«submit_block», on_submitblock, COMMAND_RPC_SUBMITBLOCK)
MAP_JON_RPC_WE(«submitblock», on_submitblock, COMMAND_RPC_SUBMITBLOCK)
+ MAP_JON_RPC_WE(«generateblocks», on_generateblocks, COMMAND_RPC_GENERATEBLOCKS)

Maybe make this a restricted command. Doesn’t matter a whole lot though since it errors out when not in fake mode.

> @@ -1149,6 +1150,31 @@ namespace cryptonote
END_KV_SERIALIZE_MAP()
};
};

nettype isn’t serialized

> + ‘status’,
+ ‘target’,
+ ‘target_height’,
+ ‘testnet’,
+ ‘top_block_hash’,
+ ‘tx_count’,
+ ‘tx_pool_size’,
+ ‘untrusted’,
+ ‘was_bootstrap_ever_used’,
+ ‘white_peerlist_size’
+ ]
+
+ daemon = Daemon()
+ res = daemon.get_info()
+
+ assert sorted(res.keys()) == sorted(keys)

This means every time someone adds something, this has to be updated too, for no other reason that there is a list above. That sounds a bit like busy work maybe. How about just check all keys you are testing (free space and height here) are present instead ?

> + ‘tx_pool_size’,
+ ‘untrusted’,
+ ‘was_bootstrap_ever_used’,
+ ‘white_peerlist_size’
+ ]
+
+ daemon = Daemon()
+ res = daemon.get_info()
+
+ assert sorted(res.keys()) == sorted(keys)
+
+ # free_space should be >= 0
+ assert res[‘free_space’] >= 0
+
+ # height should be greater or equal to 0
+ assert res[‘height’] >= 0

Height should never be 0, the genesis block is supposed to be added on init. If not, bug.

> +
+ def make_uniform_destinations(self, address, transfer_amount, transfer_number_of_destinations=1):
+ destinations = []
+ for i in range(transfer_number_of_destinations):
+ destinations.append({‘amount’:transfer_amount,’address’:address})
+ return destinations
+
+ def make_destinations(self, addresses, transfer_amounts):
+ destinations = []
+ for i in range(len(addresses)):
+ destinations.append({‘amount’:transfer_amounts[i],’address’:addresses[i]})
+ return destinations
+
+ def transfer(self, destinations, ringsize=7, payment_id=»):
+ transfer = {
+ ‘method’: ‘transfer’,

For the record, transfer is kind of obsolete. You want to use transfer_split nowadays.

> + for i in range(len(addresses)):
+ destinations.append({‘amount’:transfer_amounts[i],’address’:addresses[i]})
+ return destinations
+
+ def transfer(self, destinations, ringsize=7, payment_id=»):
+ transfer = {
+ ‘method’: ‘transfer’,
+ ‘params’: {
+ ‘destinations’: destinations,
+ ‘mixin’ : ringsize — 1,
+ ‘get_tx_key’ : True
+ },
+ ‘jsonrpc’: ‘2.0’,
+ ‘id’: ‘0’
+ }
+ if(len(payment_id) > 1):

Odd test. Payment IDs are fixed length (8 bytes or 32 bytes, twice those if in hex or course). If you just want to test whether empty, > 0.

Добавить комментарий