Closed yangl1996 closed 5 years ago
So:
Correct! Construct blocks by hand, but use existing functions for all other tasks, so no mining and no validation. I just updated the description to include wallet.
It is intended to test the confirmation logic. Wallet, UTXO set, etc. are just used to check the results.
Btw, please branch off master instead of reusing existing local branch. Thanks!
No problem!
this looks good?
assert_eq!(config::NUM_VOTER_CHAINS, 3, "please set NUM_VOTER_CHAINS to 3 to run this test.");
let's try to make the test independent of the number of chains
we want to test for those scenarios (to be added more):
we need a block creator, whose input are parent and content. also it can increment the timestamp automatically. function or macro or?
Either function or macro is fine. Note that we need to randomize the extra_content field of the block, or it's very easy to create two blocks with the same hash.
proposer_block!(parent_hash, proposer_refs, transaction_refs)
voter_block!(parent_hash, voter_parent_hash, votes)
transaction_block!(parent_hash, transactions)
It'd great if we could put those macros under the corresponding block modules, i.e. put proposer_block!
(or its function version) at block::proposer::tests
and make this macro (or function) public, and then use this function anywhere in the test where we need to generate a block. Since tests
only gets compiled when running the test, we don't add overhead for compilation.
Either function or macro is fine. Note that we need to randomize the extra_content field of the block, or it's very easy to create two blocks with the same hash.
proposer_block!(parent_hash, proposer_refs, transaction_refs)
voter_block!(parent_hash, voter_parent_hash, votes)
transaction_block!(parent_hash, transactions)
It'd great if we could put those macros under the corresponding block modules, i.e. put
proposer_block!
(or its function version) atblock::proposer::tests
and make this macro (or function) public, and then use this function anywhere in the test where we need to generate a block. Sincetests
only gets compiled when running the test, we don't add overhead for compilation.
if we have a random nonce, then we don't need a random extra content?
Yeah, setting the nonce to be random will also work.
On May 20, 2019, at 6:54 PM, wgr523 notifications@github.com wrote:
Either function or macro is fine. Note that we need to randomize the extra_content field of the block, or it's very easy to create two blocks with the same hash.
proposer_block!(parent_hash, proposer_refs, transaction_refs) voter_block!(parent_hash, voter_parent_hash, votes) transaction_block!(parent_hash, transactions) It'd great if we could put those macros under the corresponding block modules, i.e. put proposer_block! (or its function version) at block::proposer::tests and make this macro (or function) public, and then use this function anywhere in the test where we need to generate a block. Since tests only gets compiled when running the test, we don't add overhead for compilation.
if we have a random nonce, then we don't need a random extra content?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/yangl1996/prism-rust/issues/22?email_source=notifications&email_token=AAOSIYMP5IVV5NJC44V7DETPWMT4BA5CNFSM4HM3TD32YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODV2JAKI#issuecomment-494178345, or mute the thread https://github.com/notifications/unsubscribe-auth/AAOSIYLO2ZNTDVQ43KQZYSLPWMT4BANCNFSM4HM3TD3Q.
Closed in #44
Write an integration test for the blockchain module, like the
blockchain_growing
test we had for the previous version. It should/tests
.Here’s the overall flow:
blockdb
,blockchain
,wallet
, andutxodb
.insert
onblockdb
andblockchain
. It may be a good idea to write some macros/functions to help construct those blocks, but let’s discuss how they should look like and where should they live, before actually coding any.blockchain.insert
will return a diff of proposer block sequence. Call functions inhandlers
to update the UTXO set.