-
Notifications
You must be signed in to change notification settings - Fork 362
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: moul <94029+moul@users.noreply.github.com>
- Loading branch information
Showing
2 changed files
with
132 additions
and
0 deletions.
There are no files selected for viewing
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,66 @@ | ||
// SEND: 1234567890ugnot | ||
package main | ||
|
||
import "std" | ||
|
||
func main() { | ||
banktestAddr := std.DerivePkgAddr("gno.land/r/demo/gnofundme") | ||
mainaddr := std.DerivePkgAddr("main") | ||
std.TestSetOrigCaller(mainaddr) | ||
std.TestSetOrigPkgAddr(banktestAddr) | ||
banker := std.GetBanker(std.BankerTypeRealmSend) | ||
mainbal := banker.GetCoins(mainaddr) | ||
println(mainbal) | ||
/* | ||
// Setup | ||
// get and print balance of mainaddr. | ||
// with the SEND, + 200 gnot given by the TestContext, main should have 300gnot. | ||
ctype := 0 | ||
title := "Campaign for Withdrawal" | ||
description := "Description for Withdrawal" | ||
goal := int64(1000) | ||
begin := time.Now() | ||
deadline := begin.Add(time.Second * 1) | ||
ownerAddress := testutils.TestAddress("owner") | ||
beneficiaryAddress := testutils.TestAddress("beneficiary") | ||
std.TestSetOrigCaller(beneficiaryAddress) | ||
NewUser("Beneficiary", "") | ||
std.TestSetOrigCaller(ownerAddress) | ||
NewUser("Owner", "") | ||
NewCampaign(ctype, title, description, goal, begin.Unix(), deadline.Unix(), beneficiaryAddress) | ||
// Add contributions to the campaign | ||
contributorAddress := testutils.TestAddress("contributor") | ||
std.TestSetOrigCaller(contributorAddress) | ||
NewUser("Contributor", "") | ||
var amount int64 = 500 | ||
display := true | ||
// date := time.Unix(time.Now().Unix(), 0) | ||
banker.SendCoins(banktestAddr, mainaddr, std.Coins{{"ugnot", 500}}) | ||
std.TestSetOrigSend(std.Coins{{"ugnot", 500}}, nil) | ||
AddContributor("0", display) | ||
// Fast forward time to after the campaign deadline | ||
// Simulate time passing | ||
// time.Sleep(time.Second * 2) | ||
// deadline = time.Now().Add(-time.Second * 1) | ||
std.TestSetOrigCaller(ownerAddress) | ||
std.TestSkipHeights(1) | ||
// Withdraw funds | ||
Withdraw("0") | ||
// Verify | ||
if campaignsTotal["0"] != 0 { | ||
t.Errorf("Expected campaignsTotal to be 0 after withdrawal, got %d", campaignsTotal["0"]) | ||
} | ||
beneficiaryBalance := banker.GetCoins(beneficiaryAddress).AmountOf("ugnot") | ||
if beneficiaryBalance != amount { | ||
t.Errorf("Expected beneficiary balance to be %d, got %d", amount, beneficiaryBalance) | ||
} | ||
*/ | ||
} | ||
|
||
// Output: | ||
// 1434567890ugnot |
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,66 @@ | ||
// SEND: 1234567890ugnot | ||
package main | ||
|
||
import "std" | ||
|
||
func main() { | ||
banktestAddr := std.DerivePkgAddr("gno.land/r/demo/gnofundme") | ||
mainaddr := std.DerivePkgAddr("main") | ||
std.TestSetOrigCaller(mainaddr) | ||
std.TestSetOrigPkgAddr(banktestAddr) | ||
banker := std.GetBanker(std.BankerTypeRealmSend) | ||
mainbal := banker.GetCoins(mainaddr) | ||
println(mainbal) | ||
/* | ||
// Setup | ||
// get and print balance of mainaddr. | ||
// with the SEND, + 200 gnot given by the TestContext, main should have 300gnot. | ||
ctype := 0 | ||
title := "Campaign for Withdrawal" | ||
description := "Description for Withdrawal" | ||
goal := int64(1000) | ||
begin := time.Now() | ||
deadline := begin.Add(time.Second * 1) | ||
ownerAddress := testutils.TestAddress("owner") | ||
beneficiaryAddress := testutils.TestAddress("beneficiary") | ||
std.TestSetOrigCaller(beneficiaryAddress) | ||
NewUser("Beneficiary", "") | ||
std.TestSetOrigCaller(ownerAddress) | ||
NewUser("Owner", "") | ||
NewCampaign(ctype, title, description, goal, begin.Unix(), deadline.Unix(), beneficiaryAddress) | ||
// Add contributions to the campaign | ||
contributorAddress := testutils.TestAddress("contributor") | ||
std.TestSetOrigCaller(contributorAddress) | ||
NewUser("Contributor", "") | ||
var amount int64 = 500 | ||
display := true | ||
// date := time.Unix(time.Now().Unix(), 0) | ||
banker.SendCoins(banktestAddr, mainaddr, std.Coins{{"ugnot", 500}}) | ||
std.TestSetOrigSend(std.Coins{{"ugnot", 500}}, nil) | ||
AddContributor("0", display) | ||
// Fast forward time to after the campaign deadline | ||
// Simulate time passing | ||
// time.Sleep(time.Second * 2) | ||
// deadline = time.Now().Add(-time.Second * 1) | ||
std.TestSetOrigCaller(ownerAddress) | ||
std.TestSkipHeights(1) | ||
// Withdraw funds | ||
Withdraw("0") | ||
// Verify | ||
if campaignsTotal["0"] != 0 { | ||
t.Errorf("Expected campaignsTotal to be 0 after withdrawal, got %d", campaignsTotal["0"]) | ||
} | ||
beneficiaryBalance := banker.GetCoins(beneficiaryAddress).AmountOf("ugnot") | ||
if beneficiaryBalance != amount { | ||
t.Errorf("Expected beneficiary balance to be %d, got %d", amount, beneficiaryBalance) | ||
} | ||
*/ | ||
} | ||
|
||
// Output: | ||
// 1434567890ugnot |