diff --git a/gno/r/dao_realm/dao_realm_test.gno b/gno/r/dao_realm/dao_realm_test.gno index 202b4772a7..dc8ce2ff4c 100644 --- a/gno/r/dao_realm/dao_realm_test.gno +++ b/gno/r/dao_realm/dao_realm_test.gno @@ -1,10 +1,10 @@ package dao_realm import ( - "fmt" "testing" "gno.land/p/demo/json" + "gno.land/p/demo/ufmt" "gno.land/p/teritori/dao_voting_group" "gno.land/p/teritori/havl" ) @@ -37,7 +37,7 @@ func TestUpdateMembers(t *testing.T) { var membersJSON string { - id := ProposeJSON(0, fmt.Sprintf(`{"title": "Test prop", "description": "A description", "messages": [{"type": "gno.land/p/teritori/dao_voting_group.UpdateMembers", "payload": [{"power": "2", "address": "g18syxa0vh0vmne90mwhtynjet0zgeqf6prh3ryy"}]}]}`)) + id := ProposeJSON(0, ufmt.Sprintf(`{"title": "Test prop", "description": "A description", "messages": [{"type": "gno.land/p/teritori/dao_voting_group.UpdateMembers", "payload": [{"power": "2", "address": "g18syxa0vh0vmne90mwhtynjet0zgeqf6prh3ryy"}]}]}`)) VoteJSON(0, id, `{"vote": "Yes", "rationale": "testing"}`) Execute(0, id) members := group.GetMembers("", "", 0, havl.Latest) @@ -47,7 +47,7 @@ func TestUpdateMembers(t *testing.T) { } membersJSON = json.ArrayNode("", iSlice).String() - expected := fmt.Sprintf(`[{"address":"g108cszmcvs4r3k67k7h5zuhm4el3qhlrxzhshtv","power":"1"},{"address":"g14u5eaheavy0ux4dmpykg2gvxpvqvexm9cyg58a","power":"1"},{"address":"g1747t5m2f08plqjlrjk2q0qld7465hxz8gkx59c","power":"1"},{"address":"g18syxa0vh0vmne90mwhtynjet0zgeqf6prh3ryy","power":"2"},{"address":"g1ckn395mpttp0vupgtratyufdaakgh8jgkmr3ym","power":"1"},{"address":"g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm","power":"1"}]`) + expected := ufmt.Sprintf(`[{"address":"g108cszmcvs4r3k67k7h5zuhm4el3qhlrxzhshtv","power":"1"},{"address":"g14u5eaheavy0ux4dmpykg2gvxpvqvexm9cyg58a","power":"1"},{"address":"g1747t5m2f08plqjlrjk2q0qld7465hxz8gkx59c","power":"1"},{"address":"g18syxa0vh0vmne90mwhtynjet0zgeqf6prh3ryy","power":"2"},{"address":"g1ckn395mpttp0vupgtratyufdaakgh8jgkmr3ym","power":"1"},{"address":"g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm","power":"1"}]`) if membersJSON != expected { t.Errorf("Expected:\n%s\nGot:\n%s", expected, membersJSON) } @@ -67,7 +67,7 @@ func TestUpdateMembers(t *testing.T) { var member dao_voting_group.Member member.FromJSON(children[0]) - id := ProposeJSON(0, fmt.Sprintf(`{"title": "Test prop 2", "description": "A description", "messages": [{"type": "gno.land/p/teritori/dao_voting_group.UpdateMembers", "payload": [{"address": "%s", "power": "0"}]}]}`, member.Address.String())) + id := ProposeJSON(0, ufmt.Sprintf(`{"title": "Test prop 2", "description": "A description", "messages": [{"type": "gno.land/p/teritori/dao_voting_group.UpdateMembers", "payload": [{"address": "%s", "power": "0"}]}]}`, member.Address.String())) VoteJSON(0, id, `{"vote": "Yes", "rationale": "testing"}`) Execute(0, id) members := group.GetMembers("", "", 0, havl.Latest) @@ -93,11 +93,11 @@ func TestUpdateSettings(t *testing.T) { // not sure why but in this test the proposal ids start at 3 and the voting power is 5 when all tests are run, shouldn't tests be isolated? TODO: investigate { - id := ProposeJSON(0, fmt.Sprintf(`{"title": "Test prop", "description": "A description", "messages": [{"type": "gno.land/p/teritori/dao_proposal_single.UpdateSettings", "payload": {"threshold": {"thresholdQuorum": {"threshold": {"percent": 200}, "quorum": {"percent": 200}}}}}]}`)) + id := ProposeJSON(0, ufmt.Sprintf(`{"title": "Test prop", "description": "A description", "messages": [{"type": "gno.land/p/teritori/dao_proposal_single.UpdateSettings", "payload": {"threshold": {"thresholdQuorum": {"threshold": {"percent": 200}, "quorum": {"percent": 200}}}}}]}`)) VoteJSON(0, id, `{"vote": "Yes", "rationale": "testing"}`) Execute(0, id) proposalJSON := getProposalJSON(0, id) - expected := fmt.Sprintf(`{"id":"%d","title":"Test prop","description":"A description","proposer":"g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm","startHeight":"123","totalPower":"6","messages":[{"type":"gno.land/p/teritori/dao_proposal_single.UpdateSettings","payload":{"threshold":{"thresholdQuorum":{"threshold":{"percent":200},"quorum":{"percent":200}}}}}],"status":"Executed","votes":{"yes":"1","no":"0","abstain":"0"},"allowRevoting":false,"ballots":{"g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm":{"power":"1","vote":"Yes","rationale":"testing"}},"expiration":{"atTime":"2009-03-27T23:31:30Z"},"threshold":{"thresholdQuorum":{"threshold":{"percent":100},"quorum":{"percent":100}}}}`, id) + expected := ufmt.Sprintf(`{"id":"%d","title":"Test prop","description":"A description","proposer":"g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm","startHeight":"123","totalPower":"6","messages":[{"type":"gno.land/p/teritori/dao_proposal_single.UpdateSettings","payload":{"threshold":{"thresholdQuorum":{"threshold":{"percent":200},"quorum":{"percent":200}}}}}],"status":"Executed","votes":{"yes":"1","no":"0","abstain":"0"},"allowRevoting":false,"ballots":{"g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm":{"power":"1","vote":"Yes","rationale":"testing"}},"expiration":{"atTime":"2009-03-27T23:31:30Z"},"threshold":{"thresholdQuorum":{"threshold":{"percent":100},"quorum":{"percent":100}}}}`, id) if proposalJSON != expected { t.Fatalf("Expected:\n%s\nGot:\n%s", expected, proposalJSON) } @@ -105,11 +105,11 @@ func TestUpdateSettings(t *testing.T) { { // make sentiment proposal - id := ProposeJSON(0, fmt.Sprintf(`{"title": "Test prop", "description": "A description", "messages": []}`)) + id := ProposeJSON(0, ufmt.Sprintf(`{"title": "Test prop", "description": "A description", "messages": []}`)) VoteJSON(0, id, `{"vote": "Yes", "rationale": "testing"}`) Execute(0, id) proposalJSON := getProposalJSON(0, id) - expected := fmt.Sprintf(`{"id":"%d","title":"Test prop","description":"A description","proposer":"g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm","startHeight":"123","totalPower":"6","messages":[],"status":"Executed","votes":{"yes":"1","no":"0","abstain":"0"},"allowRevoting":false,"ballots":{"g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm":{"power":"1","vote":"Yes","rationale":"testing"}},"expiration":{"atTime":"2009-03-27T23:31:30Z"},"threshold":{"thresholdQuorum":{"threshold":{"percent":200},"quorum":{"percent":200}}}}`, id) + expected := ufmt.Sprintf(`{"id":"%d","title":"Test prop","description":"A description","proposer":"g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm","startHeight":"123","totalPower":"6","messages":[],"status":"Executed","votes":{"yes":"1","no":"0","abstain":"0"},"allowRevoting":false,"ballots":{"g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm":{"power":"1","vote":"Yes","rationale":"testing"}},"expiration":{"atTime":"2009-03-27T23:31:30Z"},"threshold":{"thresholdQuorum":{"threshold":{"percent":200},"quorum":{"percent":200}}}}`, id) if proposalJSON != expected { t.Fatalf("Expected:\n%s\nGot:\n%s", expected, proposalJSON) } diff --git a/gno/r/dao_roles_realm.gno/dao_roles_realm_test.gno b/gno/r/dao_roles_realm.gno/dao_roles_realm_test.gno index aa817a27a9..bba0f96176 100644 --- a/gno/r/dao_roles_realm.gno/dao_roles_realm_test.gno +++ b/gno/r/dao_roles_realm.gno/dao_roles_realm_test.gno @@ -1,10 +1,10 @@ package dao_roles_realm import ( - "fmt" "testing" "gno.land/p/demo/json" + "gno.land/p/demo/ufmt" "gno.land/p/teritori/dao_voting_group" "gno.land/p/teritori/havl" ) @@ -37,7 +37,7 @@ func TestUpdateMembers(t *testing.T) { var membersJSON string { - id := ProposeJSON(0, fmt.Sprintf(`{"title": "Test prop", "description": "A description", "messages": [{"type": "gno.land/p/teritori/dao_voting_group.UpdateMembers", "payload": [{"power": "2", "address": "g18syxa0vh0vmne90mwhtynjet0zgeqf6prh3ryy"}]}]}`)) + id := ProposeJSON(0, ufmt.Sprintf(`{"title": "Test prop", "description": "A description", "messages": [{"type": "gno.land/p/teritori/dao_voting_group.UpdateMembers", "payload": [{"power": "2", "address": "g18syxa0vh0vmne90mwhtynjet0zgeqf6prh3ryy"}]}]}`)) VoteJSON(0, id, `{"vote": "Yes", "rationale": "testing"}`) Execute(0, id) members := group.GetMembers("", "", 0, havl.Latest) @@ -47,7 +47,7 @@ func TestUpdateMembers(t *testing.T) { } membersJSON = json.ArrayNode("", iSlice).String() - expected := fmt.Sprintf(`[{"address":"g108cszmcvs4r3k67k7h5zuhm4el3qhlrxzhshtv","power":"1"},{"address":"g14u5eaheavy0ux4dmpykg2gvxpvqvexm9cyg58a","power":"1"},{"address":"g1747t5m2f08plqjlrjk2q0qld7465hxz8gkx59c","power":"1"},{"address":"g18syxa0vh0vmne90mwhtynjet0zgeqf6prh3ryy","power":"2"},{"address":"g1ckn395mpttp0vupgtratyufdaakgh8jgkmr3ym","power":"1"},{"address":"g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm","power":"1"}]`) + expected := ufmt.Sprintf(`[{"address":"g108cszmcvs4r3k67k7h5zuhm4el3qhlrxzhshtv","power":"1"},{"address":"g14u5eaheavy0ux4dmpykg2gvxpvqvexm9cyg58a","power":"1"},{"address":"g1747t5m2f08plqjlrjk2q0qld7465hxz8gkx59c","power":"1"},{"address":"g18syxa0vh0vmne90mwhtynjet0zgeqf6prh3ryy","power":"2"},{"address":"g1ckn395mpttp0vupgtratyufdaakgh8jgkmr3ym","power":"1"},{"address":"g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm","power":"1"}]`) if membersJSON != expected { t.Errorf("Expected:\n%s\nGot:\n%s", expected, membersJSON) } @@ -67,7 +67,7 @@ func TestUpdateMembers(t *testing.T) { var member dao_voting_group.Member member.FromJSON(children[0]) - id := ProposeJSON(0, fmt.Sprintf(`{"title": "Test prop 2", "description": "A description", "messages": [{"type": "gno.land/p/teritori/dao_voting_group.UpdateMembers", "payload": [{"address": "%s", "power": "0"}]}]}`, member.Address.String())) + id := ProposeJSON(0, ufmt.Sprintf(`{"title": "Test prop 2", "description": "A description", "messages": [{"type": "gno.land/p/teritori/dao_voting_group.UpdateMembers", "payload": [{"address": "%s", "power": "0"}]}]}`, member.Address.String())) VoteJSON(0, id, `{"vote": "Yes", "rationale": "testing"}`) Execute(0, id) members := group.GetMembers("", "", 0, havl.Latest) @@ -93,11 +93,11 @@ func TestUpdateSettings(t *testing.T) { // not sure why but in this test the proposal ids start at 3 and the voting power is 5 when all tests are run, shouldn't tests be isolated? TODO: investigate { - id := ProposeJSON(0, fmt.Sprintf(`{"title": "Test prop", "description": "A description", "messages": [{"type": "gno.land/p/teritori/dao_proposal_single.UpdateSettings", "payload": {"threshold": {"thresholdQuorum": {"threshold": {"percent": 200}, "quorum": {"percent": 200}}}}}]}`)) + id := ProposeJSON(0, ufmt.Sprintf(`{"title": "Test prop", "description": "A description", "messages": [{"type": "gno.land/p/teritori/dao_proposal_single.UpdateSettings", "payload": {"threshold": {"thresholdQuorum": {"threshold": {"percent": 200}, "quorum": {"percent": 200}}}}}]}`)) VoteJSON(0, id, `{"vote": "Yes", "rationale": "testing"}`) Execute(0, id) proposalJSON := getProposalJSON(0, id) - expected := fmt.Sprintf(`{"id":"%d","title":"Test prop","description":"A description","proposer":"g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm","startHeight":"123","totalPower":"6","messages":[{"type":"gno.land/p/teritori/dao_proposal_single.UpdateSettings","payload":{"threshold":{"thresholdQuorum":{"threshold":{"percent":200},"quorum":{"percent":200}}}}}],"status":"Executed","votes":{"yes":"1","no":"0","abstain":"0"},"allowRevoting":false,"ballots":{"g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm":{"power":"1","vote":"Yes","rationale":"testing"}},"expiration":{"atTime":"2009-03-27T23:31:30Z"},"threshold":{"thresholdQuorum":{"threshold":{"percent":100},"quorum":{"percent":100}}}}`, id) + expected := ufmt.Sprintf(`{"id":"%d","title":"Test prop","description":"A description","proposer":"g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm","startHeight":"123","totalPower":"6","messages":[{"type":"gno.land/p/teritori/dao_proposal_single.UpdateSettings","payload":{"threshold":{"thresholdQuorum":{"threshold":{"percent":200},"quorum":{"percent":200}}}}}],"status":"Executed","votes":{"yes":"1","no":"0","abstain":"0"},"allowRevoting":false,"ballots":{"g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm":{"power":"1","vote":"Yes","rationale":"testing"}},"expiration":{"atTime":"2009-03-27T23:31:30Z"},"threshold":{"thresholdQuorum":{"threshold":{"percent":100},"quorum":{"percent":100}}}}`, id) if proposalJSON != expected { t.Fatalf("Expected:\n%s\nGot:\n%s", expected, proposalJSON) } @@ -105,11 +105,11 @@ func TestUpdateSettings(t *testing.T) { { // make sentiment proposal - id := ProposeJSON(0, fmt.Sprintf(`{"title": "Test prop", "description": "A description", "messages": []}`)) + id := ProposeJSON(0, ufmt.Sprintf(`{"title": "Test prop", "description": "A description", "messages": []}`)) VoteJSON(0, id, `{"vote": "Yes", "rationale": "testing"}`) Execute(0, id) proposalJSON := getProposalJSON(0, id) - expected := fmt.Sprintf(`{"id":"%d","title":"Test prop","description":"A description","proposer":"g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm","startHeight":"123","totalPower":"6","messages":[],"status":"Executed","votes":{"yes":"1","no":"0","abstain":"0"},"allowRevoting":false,"ballots":{"g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm":{"power":"1","vote":"Yes","rationale":"testing"}},"expiration":{"atTime":"2009-03-27T23:31:30Z"},"threshold":{"thresholdQuorum":{"threshold":{"percent":200},"quorum":{"percent":200}}}}`, id) + expected := ufmt.Sprintf(`{"id":"%d","title":"Test prop","description":"A description","proposer":"g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm","startHeight":"123","totalPower":"6","messages":[],"status":"Executed","votes":{"yes":"1","no":"0","abstain":"0"},"allowRevoting":false,"ballots":{"g1wymu47drhr0kuq2098m792lytgtj2nyx77yrsm":{"power":"1","vote":"Yes","rationale":"testing"}},"expiration":{"atTime":"2009-03-27T23:31:30Z"},"threshold":{"thresholdQuorum":{"threshold":{"percent":200},"quorum":{"percent":200}}}}`, id) if proposalJSON != expected { t.Fatalf("Expected:\n%s\nGot:\n%s", expected, proposalJSON) } diff --git a/gno/r/launchpad_grc20/airdrop_grc20_test.gno b/gno/r/launchpad_grc20/airdrop_grc20_test.gno index 11f260341f..696fd53fab 100644 --- a/gno/r/launchpad_grc20/airdrop_grc20_test.gno +++ b/gno/r/launchpad_grc20/airdrop_grc20_test.gno @@ -1,13 +1,13 @@ package launchpad_grc20 import ( - "fmt" "std" "strconv" "testing" "time" "gno.land/p/demo/merkle" + "gno.land/p/demo/ufmt" ) func TestNewAirdrop(t *testing.T) { @@ -175,18 +175,12 @@ func TestClaimJSON(t *testing.T) { root := tree.Root() proofs, _ := tree.Proof(leaves[0]) - erroneousProofs := []merkle.Node{ - {[]byte("badproof")}, - {[]byte("badproof")}, - } - - now := time.Now().Unix() NewToken("TestClaimJSONAirDropToken", "TestClaimJSONAirDropToken", "noimage", 18, 21_000_000, 23_000_000, true, true) airdropID := NewAirdrop("TestClaimJSONAirDropToken", root, 100, 0, 0) proofsJSON := "[" for i, proof := range proofs { - proofsJSON += fmt.Sprintf("{\"hash\":\"%s\", \"pos\":\"%s\"}", proof.Hash(), strconv.Itoa(int(proof.Position()))) + proofsJSON += ufmt.Sprintf("{\"hash\":\"%s\", \"pos\":\"%s\"}", proof.Hash(), strconv.Itoa(int(proof.Position()))) if i != len(proofs)-1 { proofsJSON += ", " } @@ -259,8 +253,8 @@ func TestClaim(t *testing.T) { proofs, _ := tree.Proof(leaves[0]) erroneousProofs := []merkle.Node{ - {[]byte("badproof")}, - {[]byte("badproof")}, + merkle.NewNode([]byte("badproof"), 0), + merkle.NewNode([]byte("badproof"), 0), } now := time.Now().Unix() diff --git a/gno/r/launchpad_grc20/sale_grc20_test.gno b/gno/r/launchpad_grc20/sale_grc20_test.gno index 7aaa49b485..686b337ca2 100644 --- a/gno/r/launchpad_grc20/sale_grc20_test.gno +++ b/gno/r/launchpad_grc20/sale_grc20_test.gno @@ -331,7 +331,6 @@ func TestBuy(t *testing.T) { badCoin := std.NewCoins(std.NewCoin("notugnot", 100*10)) manyCoins := std.NewCoins(std.NewCoin("ugnot", 100*10), std.NewCoin("notugnot", 100*10)) notEnoughCoins := std.NewCoins(std.NewCoin("ugnot", 100*5)) - tooManyCoins := std.NewCoins(std.NewCoin("ugnot", 100*11)) emptyCoins := std.NewCoins() tests := testBuyTestTable{ @@ -536,7 +535,7 @@ func TestFinalize(t *testing.T) { NewToken("TestFinalizeToken", "TestFinalizeToken", "image", 18, 21_000_000, 23_000_000, true, true) saleID := NewSale("TestFinalizeToken", "", startTimestamp, endTimestamp, 100, 15, 10, 20, true) onGoingSaleID := NewSale("TestFinalizeToken", "", startTimestamp, onGoingEndTimestamp, 100, 15, 10, 20, true) - onGoingSaleID2 := NewSale("TestFinalizeToken", "", startTimestamp, onGoingEndTimestamp2, 100, 15, 10, 20, true) + _ = NewSale("TestFinalizeToken", "", startTimestamp, onGoingEndTimestamp2, 100, 15, 10, 20, true) tests := testFinalizeTestTable{ "Success with 0 tokens sold": { diff --git a/gno/r/social_feeds/feeds_test.gno b/gno/r/social_feeds/feeds_test.gno index 86766e7127..caf6380051 100644 --- a/gno/r/social_feeds/feeds_test.gno +++ b/gno/r/social_feeds/feeds_test.gno @@ -170,7 +170,7 @@ func testCreateAndDeleteComment(t *testing.T) { metadata := `empty_meta_data` - commentID1 := CreatePost(feed1.id, post1.id, cat1, metadata) + _ = CreatePost(feed1.id, post1.id, cat1, metadata) commentID2 := CreatePost(feed1.id, post1.id, cat1, metadata) comment2 := feed1.MustGetPost(commentID2) @@ -255,10 +255,10 @@ func testFilterByCategories(t *testing.T) { postID2 := CreatePost(feed2.id, rootPostID, cat1, "metadata") // Create 1 posts on root with cat2 - postID3 := CreatePost(feed2.id, rootPostID, cat2, "metadata") + _ = CreatePost(feed2.id, rootPostID, cat2, "metadata") // Create comments on post 1 - commentPostID1 := CreatePost(feed2.id, postID1, cat1, "metadata") + _ = CreatePost(feed2.id, postID1, cat1, "metadata") // cat1: Should return max = limit if count := countPosts(feed2.id, filter_cat1, 1); count != 1 { @@ -313,11 +313,11 @@ func testFilterByCategories(t *testing.T) { func testTipPost(t *testing.T) { creator := testutils.TestAddress("creator") - std.TestIssueCoins(creator, std.Coins{{"ugnot", 100_000_000}}) + std.TestIssueCoins(creator, std.Coins{{Denom: "ugnot", Amount: 100_000_000}}) // NOTE: Dont know why the address should be this to be able to call banker (= std.GetCallerAt(1)) tipper := testutils.TestAddress("tipper") - std.TestIssueCoins(tipper, std.Coins{{"ugnot", 50_000_000}}) + std.TestIssueCoins(tipper, std.Coins{{Denom: "ugnot", Amount: 50_000_000}}) banker := std.GetBanker(std.BankerTypeReadonly) @@ -341,7 +341,7 @@ func testTipPost(t *testing.T) { // Tiper tips the ppst std.TestSetOrigCaller(tipper) - std.TestSetOrigSend(std.Coins{{"ugnot", 1_000_000}}, nil) + std.TestSetOrigSend(std.Coins{{Denom: "ugnot", Amount: 1_000_000}}, nil) TipPost(feed3.id, post1.id) // Coin must be increased for creator @@ -355,7 +355,7 @@ func testTipPost(t *testing.T) { } // Add more tip should update this total - std.TestSetOrigSend(std.Coins{{"ugnot", 2_000_000}}, nil) + std.TestSetOrigSend(std.Coins{{Denom: "ugnot", Amount: 2_000_000}}, nil) TipPost(feed3.id, post1.id) if post1.tipAmount != 3_000_000 { @@ -426,7 +426,7 @@ func testHidePostForMe(t *testing.T) { feed8 := mustGetFeed(feedID8) postIDToHide := CreatePost(feed8.id, rootPostID, cat1, `{"metadata": "value"}`) - postID := CreatePost(feed8.id, rootPostID, cat1, `{"metadata": "value"}`) + _ = CreatePost(feed8.id, rootPostID, cat1, `{"metadata": "value"}`) if count := countPosts(feed8.id, filter_all, 10); count != 2 { t.Fatalf("expected posts count: 2, got %q.", count)