forked from 0LNetworkCommunity/libra-legacy-v6
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add unit tests for thermostat. Patch a couple bugs
- Loading branch information
1 parent
68e566e
commit 03f25e8
Showing
23 changed files
with
290 additions
and
97 deletions.
There are no files selected for viewing
Binary file modified
BIN
-2 Bytes
(100%)
...ework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/EpochBoundary.mv
Binary file not shown.
Binary file modified
BIN
+81 Bytes
(100%)
...ramework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/ProofOfFee.mv
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
-42 Bytes
(100%)
...ramework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/EpochBoundary.mvsm
Binary file not shown.
Binary file modified
BIN
+1.19 KB
(100%)
...m-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/ProofOfFee.mvsm
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
File renamed without changes.
1 change: 0 additions & 1 deletion
1
diem-move/diem-framework/core/transactional-tests/0L/proof_of_fee/thermostat.exp
This file was deleted.
Oops, something went wrong.
72 changes: 0 additions & 72 deletions
72
diem-move/diem-framework/core/transactional-tests/0L/proof_of_fee/thermostat.move
This file was deleted.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
...move/diem-framework/core/transactional-tests/0L/proof_of_fee/thermostat_decrease_long.exp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
processed 2 tasks |
56 changes: 56 additions & 0 deletions
56
...ove/diem-framework/core/transactional-tests/0L/proof_of_fee/thermostat_decrease_long.move
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
//# init --validators Alice | ||
|
||
// Scenario: The reward is too high during 5 days (short window). People are bidding over 95% of the baseline fee. | ||
|
||
|
||
//# run --admin-script --signers DiemRoot Alice | ||
script { | ||
use DiemFramework::ProofOfFee; | ||
use DiemFramework::Debug::print; | ||
use Std::Vector; | ||
|
||
fun main(vm: signer, _a_sig: signer) { | ||
|
||
let start_value = 0960; // 96% of baseline fee. | ||
let median_history = Vector::empty<u64>(); | ||
|
||
// we need at least 10 epochs above the 95% range. | ||
let i = 0; | ||
while (i < 12) { | ||
// let factor = i * 10; | ||
// let value = start_value + factor; | ||
// print(&value); | ||
Vector::push_back(&mut median_history, start_value); | ||
i = i + 1; | ||
}; | ||
|
||
|
||
ProofOfFee::test_mock_reward( | ||
&vm, | ||
100, | ||
50, | ||
33, | ||
median_history, | ||
); | ||
|
||
// no changes until we run the thermostat. | ||
let (value, clearing, median) = ProofOfFee::get_consensus_reward(); | ||
assert!(value == 100, 1000); | ||
assert!(clearing == 50, 1001); | ||
assert!(median == 33, 1002); | ||
|
||
ProofOfFee::reward_thermostat(&vm); | ||
|
||
// In the decrease case during a short period, we decrease by 5% | ||
// No other parameters of consensus reward should change on calling this function. | ||
let (value, clearing, median) = ProofOfFee::get_consensus_reward(); | ||
assert!(value == 90, 1000); | ||
assert!(clearing == 50, 1001); | ||
assert!(median == 33, 1002); | ||
|
||
print(&value); | ||
print(&clearing); | ||
print(&median); | ||
|
||
} | ||
} |
1 change: 1 addition & 0 deletions
1
...ove/diem-framework/core/transactional-tests/0L/proof_of_fee/thermostat_decrease_short.exp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
processed 2 tasks |
Oops, something went wrong.