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

add integration-test for refund_grant #93

Merged
merged 2 commits into from
Aug 24, 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
2 changes: 1 addition & 1 deletion build/StarcoinFramework/BuildInfo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ compiled_package_info:
? address: "0x00000000000000000000000000000001"
name: YieldFarmingV2
: StarcoinFramework
source_digest: 7383E555375A13FC20185C03038B1A256C817A71C484233F6D7EAEE9FA1263EA
source_digest: FD04C9A39DFAD60C3FA7B7566327BD66B28ABC554C15691EFA399D36AA8EAE4B
build_flags:
dev_mode: false
test_mode: false
Expand Down
Binary file modified build/StarcoinFramework/bytecode_modules/Signature.mv
Binary file not shown.
27 changes: 27 additions & 0 deletions build/StarcoinFramework/docs/Signature.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Contains functions for [ed25519](https://en.wikipedia.org/wiki/EdDSA) digital si
- [Function `ed25519_verify`](#0x1_Signature_ed25519_verify)
- [Function `native_ecrecover`](#0x1_Signature_native_ecrecover)
- [Function `ecrecover`](#0x1_Signature_ecrecover)
- [Function `secp256k1_verify`](#0x1_Signature_secp256k1_verify)
- [Module Specification](#@Module_Specification_0)


Expand Down Expand Up @@ -115,6 +116,32 @@ recover address from ECDSA signature, if recover fail, return None



</details>

<a name="0x1_Signature_secp256k1_verify"></a>

## Function `secp256k1_verify`



<pre><code><b>public</b> <b>fun</b> <a href="Signature.md#0x1_Signature_secp256k1_verify">secp256k1_verify</a>(signature: vector&lt;u8&gt;, addr: vector&lt;u8&gt;, message: vector&lt;u8&gt;): bool
</code></pre>



<details>
<summary>Implementation</summary>


<pre><code><b>public</b> <b>fun</b> <a href="Signature.md#0x1_Signature_secp256k1_verify">secp256k1_verify</a>(signature: vector&lt;u8&gt;, addr: vector&lt;u8&gt;, message: vector&lt;u8&gt;) : bool{
<b>let</b> receover_address_opt:<a href="Option.md#0x1_Option">Option</a>&lt;<a href="Signature.md#0x1_EVMAddress">EVMAddress</a>&gt; = <a href="Signature.md#0x1_Signature_ecrecover">ecrecover</a>(message, signature);
<b>let</b> expect_address = <a href="Signature.md#0x1_EVMAddress_new">EVMAddress::new</a>(addr);
&<a href="Option.md#0x1_Option_destroy_some">Option::destroy_some</a>&lt;<a href="Signature.md#0x1_EVMAddress">EVMAddress</a>&gt;(receover_address_opt) == &expect_address
}
</code></pre>



</details>

<a name="@Module_Specification_0"></a>
Expand Down
Binary file modified build/StarcoinFramework/source_maps/EVMAddress.mvsm
Binary file not shown.
Binary file modified build/StarcoinFramework/source_maps/Signature.mvsm
Binary file not shown.
10 changes: 9 additions & 1 deletion integration-tests/daospace/dao_grant.exp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
processed 16 tasks
processed 17 tasks

task 5 'run'. lines 13-21:
{
Expand Down Expand Up @@ -65,3 +65,11 @@ task 15 'run'. lines 207-227:
"Keep": "Executed"
}
}

task 16 'run'. lines 229-243:
{
"gas_used": 192361,
"status": {
"Keep": "Executed"
}
}
16 changes: 16 additions & 0 deletions integration-tests/daospace/dao_grant.move
Original file line number Diff line number Diff line change
Expand Up @@ -224,4 +224,20 @@ script{
assert!(DAOSpace::query_grant_info_period(&grant_info) == 3600,1006);
}
}
// check: EXECUTED

//# run --signers cindy
script{
use creator::DAOHelper::{Self, X, XPlugin};
use StarcoinFramework::DAOSpace;
use StarcoinFramework::STC;

//alice create grant to cindy
fun create_grant(sender: signer){
DAOHelper::create_grant(&sender, 1000000000u128, 90000u64, 3600u64);
assert!(DAOSpace::is_have_grant<X, XPlugin, STC::STC>(@cindy) == true, 1001);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is_have_grant 是不是应该改成 has_grant @WGB5445 ?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is_have_grant 是不是应该改成 has_grant @WGB5445 ?

这里参考is_member is_some 感觉比较统一点

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is/has 都能表达 bool 状态吧, is have 感觉是重复了

DAOSpace::refund_grant<X, XPlugin, STC::STC>(&sender);
assert!(DAOSpace::is_have_grant<X, XPlugin, STC::STC>(@cindy) == false, 1002);
}
}
// check: EXECUTED