Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[integration-test] StarcoinDAO integration-test #112

Merged
merged 7 commits into from
Sep 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion build/StarcoinFramework/BuildInfo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,9 @@ compiled_package_info:
? address: "0x00000000000000000000000000000001"
name: OnChainConfigScripts
: StarcoinFramework
? address: "0x00000000000000000000000000000001"
name: OnChainStarcoinDAOConfig
: StarcoinFramework
? address: "0x00000000000000000000000000000001"
name: Option
: StarcoinFramework
Expand Down Expand Up @@ -309,7 +312,7 @@ compiled_package_info:
? address: "0x00000000000000000000000000000001"
name: YieldFarmingV2
: StarcoinFramework
source_digest: D7009E25679D370668CC815C5CF9F50E1CFFB3A9E058F2C9020F9C03179EF15A
source_digest: 25ECF2754312EBC49B1DBE3DB09DC2A65003124E9C7037B9377DACB300395E8E
build_flags:
dev_mode: false
test_mode: false
Expand Down
1 change: 1 addition & 0 deletions build/StarcoinFramework/docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ This is the root document for the Move StarcoinFramework module documentation. T
- [`0x1::Offer`](Offer.md#0x1_Offer)
- [`0x1::OnChainConfigDao`](OnChainConfigDao.md#0x1_OnChainConfigDao)
- [`0x1::OnChainConfigScripts`](OnChainConfigScripts.md#0x1_OnChainConfigScripts)
- [`0x1::OnChainStarcoinDAOConfig`](OnChainStarcoinDAOConfig.md#0x1_OnChainStarcoinDAOConfig)
- [`0x1::Option`](Option.md#0x1_Option)
- [`0x1::Oracle`](Oracle.md#0x1_Oracle)
- [`0x1::PackageTxnManager`](PackageTxnManager.md#0x1_PackageTxnManager)
Expand Down
6 changes: 3 additions & 3 deletions integration-tests/daospace/stake_to_sbt_plugin.exp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ task 5 'run'. lines 61-69:

task 6 'run'. lines 71-107:
{
"gas_used": 569552,
"gas_used": 652263,
"status": "Executed"
}

Expand Down Expand Up @@ -36,7 +36,7 @@ task 9 'run'. lines 124-137:

task 10 'run'. lines 139-155:
{
"gas_used": 336817,
"gas_used": 419528,
"status": "Executed"
}

Expand All @@ -48,7 +48,7 @@ task 12 'run'. lines 159-172:

task 13 'run'. lines 174-190:
{
"gas_used": 458338,
"gas_used": 541049,
"status": "Executed"
}

Expand Down
58 changes: 58 additions & 0 deletions integration-tests/starcoin_dao/starcoin_onchain_config.exp
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
processed 24 tasks

task 4 'run'. lines 9-17:
{
"gas_used": 1782138,
"status": "Executed"
}

task 5 'run'. lines 19-33:
{
"gas_used": 586891,
"status": "Executed"
}

task 9 'run'. lines 42-53:
{
"gas_used": 101440,
"status": "Executed"
}

task 12 'run'. lines 60-69:
{
"gas_used": 575872,
"status": "Executed"
}

task 13 'run'. lines 72-81:
{
"gas_used": 426213,
"status": "Executed"
}

task 15 'call'. lines 85-85:
"0xa7dcef9aef26202fce82a7c7d6672afb/1/0x00000000000000000000000000000001::IdentifierNFT::IdentifierNFT<0x00000000000000000000000000000001::DAOSpace::DAOMember<0x00000000000000000000000000000001::StarcoinDAO::StarcoinDAO>,0x00000000000000000000000000000001::DAOSpace::DAOMemberBody<0x00000000000000000000000000000001::StarcoinDAO::StarcoinDAO>>"

task 17 'run'. lines 90-100:
{
"gas_used": 6111871,
"status": "Executed"
}

task 19 'run'. lines 104-112:
{
"gas_used": 71778,
"status": "Executed"
}

task 21 'run'. lines 116-125:
{
"gas_used": 172856,
"status": "Executed"
}

task 23 'run'. lines 129-145:
{
"gas_used": 471985,
"status": "Executed"
}
145 changes: 145 additions & 0 deletions integration-tests/starcoin_dao/starcoin_onchain_config.move
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
//# init -n dev

//# faucet --addr Genesis --amount 1000000000000000

//# faucet --addr alice --amount 1000000000000000

//# block --author 0x1 --timestamp 86400000

//# run --signers Genesis
script{
use StarcoinFramework::StdlibUpgradeScripts;

fun main(){
StdlibUpgradeScripts::upgrade_from_v12_to_v12_1();
}
}
// check: EXECUTED

//# run --signers alice
script {
use StarcoinFramework::StakeToSBTPlugin;
use StarcoinFramework::STC;
use StarcoinFramework::Token;
use StarcoinFramework::Account;
use StarcoinFramework::StarcoinDAO::StarcoinDAO;

fun stake_and_check(sender: signer) {
let token = Account::withdraw<STC::STC>(
&sender, 1000 * Token::scaling_factor<STC::STC>());
StakeToSBTPlugin::stake<StarcoinDAO, STC::STC>(&sender, token, 60000);
}
}
// check: EXECUTED


//# block --author 0x1 --timestamp 86401000

//# block --author 0x1 --timestamp 86402000

//# call-api chain.info

//# run --signers alice --args {{$.call-api[0].head.parent_hash}}
script {
use StarcoinFramework::Block;

fun checkpoint(_account: signer, parent_hash: vector<u8>) {
let expect_parent_hash = Block::get_parent_hash();
assert!(expect_parent_hash == parent_hash, 1001);

Block::checkpoint();
}
}
// check: EXECUTED


//# block --author=0x3 --timestamp 86450000

//# call-api chain.get_block_by_hash ["{{$.call-api[0].head.parent_hash}}",{"raw":true}]

//# run --signers alice --args {{$.call-api[1].raw.header}}

script {
use StarcoinFramework::Block;

fun update(_account: signer, raw_header: vector<u8>) {
Block::update_state_root(raw_header);
}
}
// check: EXECUTED


//# run --signers alice
script {
use StarcoinFramework::OnChainStarcoinDAOConfig;
use StarcoinFramework::RewardConfig;

fun propose (sender: signer){
assert!(RewardConfig::reward_delay() == 1, 101);
OnChainStarcoinDAOConfig::propose_update_reward_config(&sender, b"update", 5 , 20000);
}
}

//# block --author=0x3 --timestamp 86520000

//# call 0x1::SnapshotUtil::get_access_path --type-args 0x1::StarcoinDAO::StarcoinDAO --args {{$.faucet[1].txn.raw_txn.decoded_payload.ScriptFunction.args[0]}}

//# call-api state.get_with_proof_by_root_raw ["{{$.call[0]}}","{{$.call-api[1].header.state_root}}"]


//# run --signers alice --args {{$.call-api[2]}}
script{
use StarcoinFramework::DAOSpace;
use StarcoinFramework::StarcoinDAO::StarcoinDAO;
// alice vote
fun cast_vote(sender: signer, snpashot_raw_proofs: vector<u8>){

DAOSpace::cast_vote_entry<StarcoinDAO>(sender, 1, snpashot_raw_proofs, 1);
}
}
// check: EXECUTED

//# block --author=0x3 --timestamp 86640000

//# run --signers alice
script{
use StarcoinFramework::DAOSpace;
use StarcoinFramework::StarcoinDAO::StarcoinDAO;
fun state(_sender: signer){
assert!(DAOSpace::proposal_state<StarcoinDAO>(1) == 4 , 103);
}
}
// check: EXECUTED

//# block --author=0x3 --timestamp 86660000

//# run --signers alice
script{
use StarcoinFramework::DAOSpace;
use StarcoinFramework::StarcoinDAO::StarcoinDAO;
fun queue_proposal_action(_sender: signer){
DAOSpace::queue_proposal_action<StarcoinDAO>(1);
assert!(DAOSpace::proposal_state<StarcoinDAO>(1) == 5 , 103);
}
}
// check: EXECUTED

//# block --author=0x3 --timestamp 86680000

//# run --signers alice
script{
use StarcoinFramework::DAOSpace;
use StarcoinFramework::StarcoinDAO::StarcoinDAO;
use StarcoinFramework::ConfigProposalPlugin;
use StarcoinFramework::RewardConfig;

fun execute_proposal(sender: signer){
assert!(DAOSpace::proposal_state<StarcoinDAO>(1) == 6 , 103);
ConfigProposalPlugin::execute_proposal<StarcoinDAO, RewardConfig::RewardConfig>(&sender, 1);
assert!(DAOSpace::proposal_state<StarcoinDAO>(1) == 7 , 104);

assert!(RewardConfig::reward_delay() == 5, 105);

}
}
// check: EXECUTED
58 changes: 58 additions & 0 deletions integration-tests/starcoin_dao/starcoin_upgrade_module.exp
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
processed 27 tasks

task 4 'run'. lines 9-17:
{
"gas_used": 1782138,
"status": "Executed"
}

task 5 'run'. lines 19-33:
{
"gas_used": 586891,
"status": "Executed"
}

task 9 'run'. lines 41-52:
{
"gas_used": 101440,
"status": "Executed"
}

task 12 'run'. lines 59-68:
{
"gas_used": 575872,
"status": "Executed"
}

task 14 'run'. lines 75-85:
{
"gas_used": 411947,
"status": "Executed"
}

task 16 'call'. lines 90-90:
"0xa7dcef9aef26202fce82a7c7d6672afb/1/0x00000000000000000000000000000001::IdentifierNFT::IdentifierNFT<0x00000000000000000000000000000001::DAOSpace::DAOMember<0x00000000000000000000000000000001::StarcoinDAO::StarcoinDAO>,0x00000000000000000000000000000001::DAOSpace::DAOMemberBody<0x00000000000000000000000000000001::StarcoinDAO::StarcoinDAO>>"

task 18 'run'. lines 95-105:
{
"gas_used": 6111871,
"status": "Executed"
}

task 20 'run'. lines 110-118:
{
"gas_used": 71778,
"status": "Executed"
}

task 22 'run'. lines 122-131:
{
"gas_used": 172856,
"status": "Executed"
}

task 24 'run'. lines 135-147:
{
"gas_used": 481723,
"status": "Executed"
}
Loading