Code Review: Clear null Account
I thought I'd go through some of the blockchain test logic to see if I can explain it. Hopefully I can interpret it clearly enough without too much jargon. In doing so, maybe I'll be able to spell out certain details for my readers.
In this example, we're looking at how it's important that the @null balance always gets zeroed out. It's part of consensus that its balance always becomes zero, no matter how funds are transferred to it. This is known as burning assets.
The logic I'm interpreting here comes from this code revision:
Case: clear_null_account
The name of this verification routine is clear_null_account
. It is intended to check if the blockchain behavior really does what the developers expect. Specifically, the developers want to know if the null
account really has a zero balance.
Setup Phase:
- Alice (
alice
) is summoned into existence as a blockchain actor. - Generate a block (simulates 3 seconds of time).
- Assets are summoned into existence, to fund
alice
:
10.000 TESTS
(similar to STEEM on testnet)10.000 TBD
(similar to SBD on testnet)
- Regular transfer operation created:
- From
alice
tonull
in the amount of1.000 TESTS
. - From
alice
tonull
in the amount of2.000 TBD
.
- STEEM Power transfer operation created (applied to
null
asVESTS
):
- From
alice
tonull
in the amount of3.000 TESTS
.
- Savings transfer operation created:
- From
alice
tonull
in the amount of4.000 TESTS
. - From
alice
tonull
in the amount of5.000 TBD
.
- Assets are summoned into existence, to further fund
null
in addition to whatalice
transferred above:
1.000 TESTS
1.000 TBD
1.000000 VESTS
(as vesting balance)1.000 TESTS
(as vesting STEEM)
- Assets are summoned into existence, to fund the blockchain:
2.000 TESTS
into the current supply.3.000 TESTS
into the virtual supply.1.000 TBD
into the current supply.1.000000 VESTS
into the rewarded vesting shares.1.000 TESTS
into the rewarded vesting STEEM.
Test Phase:
- Generate a block (simulates another 3 seconds of time), which clears all balances of
null
. - Check to see if all
null
balances are now zero (includingVESTS
). - Check to see if all
null
reward balances are now zero (includingVESTS
). - Check to see if:
- Balance of
alice
is2.000 TESTS
- Balance of
alice
is3.000 TBD
If all of the above takes place, the test case passes and we are now sure that the null
balance behaves as we expect.
Conclusion
Going through this simple test I did learn something. I knew that there were several methods of transferring assets. But it hadn't occurred that each asset was really zeroed out for null
.
This is because we typically only send SBD (TBD on testnet) to null
for post promotion. But the blockchain supports all asset types, so even reward balances and VESTS
are checked.
It makes sense that this is the case and it's great to see that this behavior is explicitly being evaluated in the tests.
I think this post has beyond my knowledge.
Really don't know what is going on here.
But I am quite sure this is a quality post.
lol
What if the null balance doesn't get zeroed out?
Then they see an error when they run the tests.
Great post, sorry I still do not understand anything. I still get there.
i consider myself something of a nerd but this went flying way above my head! You are a guru. Will try to do some background research on blockchain tests and then attempt again. Perhaps you can do an article explaining the basics for newbies. It will be very helpful. Thanks
Would love to see more posts from you. Following you. Please feel free to follow me and see my posts today if you like interesting wildlife pictures with a story like this one https://steemit.com/wildlife/@vm2904/riding-high-free-ride-with-a-meal-of-ticks, https://steemit.com/bwphotocontest/@vm2904/bwphotocontest-nature-s-artwork-of-symmetry-the-passionflower and https://steemit.com/photography/@vm2904/attitude-the-meek-shall-rule-the-earth
Please provide your comments, upvote and resteem if you like any of my blogs
This post received a 25% upvote from @randowhale thanks to @kurtbeil! For more information, click here!
nice article . kindly follow me back it will b my pleasure