forked from gnolang/gno
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
296d1f5
commit 56b0ed2
Showing
11 changed files
with
276 additions
and
39 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,70 @@ | ||
KEY = MyKey | ||
BASE = teritori | ||
REMOTE = http://127.0.0.1:26657 | ||
CHAIN_ID = dev | ||
|
||
.PHONY: add_social_feeds_realm add_utf16_pkg add_ujson_pkg add_flags_index_pkg add_dao_interfaces_pkg add_social_feed all | ||
|
||
add_agregator_realm: | ||
gnokey maketx addpkg \ | ||
-deposit="1ugnot" \ | ||
-gas-fee="1ugnot" \ | ||
-gas-wanted="50000000" \ | ||
-broadcast="true" \ | ||
-chainid="${CHAIN_ID}" \ | ||
-remote="${REMOTE}" \ | ||
-pkgdir="./r/demo/teritori/worx_aggregator" \ | ||
-pkgpath="gno.land/r/${BASE}/worx_aggregator" \ | ||
${KEY} | ||
|
||
add_random_worx_realm: | ||
gnokey maketx addpkg \ | ||
-deposit="1ugnot" \ | ||
-gas-fee="1ugnot" \ | ||
-gas-wanted="50000000" \ | ||
-broadcast="true" \ | ||
-chainid="${CHAIN_ID}" \ | ||
-remote="${REMOTE}" \ | ||
-pkgdir="./r/demo/teritori/providers/random_pusher" \ | ||
-pkgpath="gno.land/r/${BASE}/providers/random_pusher" \ | ||
${KEY} | ||
|
||
|
||
add_worx_pkg: | ||
gnokey maketx addpkg \ | ||
-deposit="1ugnot" \ | ||
-gas-fee="1ugnot" \ | ||
-gas-wanted="50000000" \ | ||
-broadcast="true" \ | ||
-chainid="${CHAIN_ID}" \ | ||
-remote="${REMOTE}" \ | ||
-pkgdir="./p/demo/teritori/worx" \ | ||
-pkgpath="gno.land/p/${BASE}/worx" \ | ||
${KEY} | ||
|
||
|
||
register_dataprovider: | ||
gnokey maketx call \ | ||
-pkgpath "gno.land/r/${BASE}/worx_aggregator" \ | ||
-func="RegisterDataProvider" \ | ||
-gas-fee="1000000ugnot" \ | ||
-gas-wanted="3000000" \ | ||
-remote="${REMOTE}" \ | ||
-chainid="${CHAIN_ID}" \ | ||
-broadcast \ | ||
-args "gno.land/r/teritori/providers/random_pusher" \ | ||
${KEY} | ||
|
||
push_worx: | ||
gnokey maketx call \ | ||
-pkgpath "gno.land/r/${BASE}/providers/random_pusher" \ | ||
-func="RandWorx" \ | ||
-gas-fee="1000000ugnot" \ | ||
-gas-wanted="3000000" \ | ||
-remote="${REMOTE}" \ | ||
-chainid="${CHAIN_ID}" \ | ||
-broadcast \ | ||
-args "g14vxq5e5pt5sev7rkz2ej438scmxtylnzv5vnkw" \ | ||
${KEY} | ||
|
||
all: add_utf16_pkg add_ujson_pkg add_flags_index_pkg add_dao_interfaces_pkg add_social_feeds_realm add_social_feed |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package worx | ||
|
||
import ( | ||
"testing" | ||
"gno.land/p/demo/rand" | ||
"gno.land/p/demo/testutils" | ||
"gno.land/p/demo/ufmt" | ||
"std" | ||
) | ||
|
||
func TestAddGet(t *testing.T) { | ||
keeper := NewWorxKeeper() | ||
user1 := testutils.TestAddress("user1") | ||
if len(keeper.Get()) != 0{ | ||
t.Fatalf("Keeper is not empty initialized") | ||
} | ||
|
||
fillRandomWorx(keeper, 10123423, user1) | ||
if len(keeper.Get()) != 1{ | ||
t.Fatalf("Keeper Worx was not added to keeper 1") | ||
} | ||
|
||
fillRandomWorx(keeper, 10123423, user1) | ||
if len(keeper.Get()) != 2{ | ||
t.Fatalf("Keeper Worx was not added to keeper 2") | ||
} | ||
} | ||
|
||
func TestGetFromDate(t *testing.T) { | ||
keeper := NewWorxKeeper() | ||
user1 := testutils.TestAddress("user1") | ||
if len(keeper.Get()) != 0{ | ||
t.Fatalf("Keeper is not empty initialized") | ||
} | ||
|
||
for i:=0; i < 100; i++ { | ||
fillRandomWorx(keeper, int64(i*10), user1) | ||
} | ||
|
||
if len(keeper.Get()) != 100{ | ||
t.Fatalf("Keeper Worx was not totally added") | ||
} | ||
|
||
if len(keeper.GetFromDate(1003)) != 0 { | ||
t.Fatalf("Get From Date Should have found 0 registers") | ||
} | ||
|
||
if len(keeper.GetFromDate(903)) != 9 { | ||
t.Fatalf("Get From Date Should have found 9 registers") | ||
} | ||
|
||
} | ||
|
||
func fillRandomWorx(keeper *WorxKeeper, timestamp int64, address std.Address){ | ||
r := rand.New() | ||
keeper.Store(NewWorx( | ||
r.Intn(25), | ||
"somekey", | ||
address, | ||
r.Intn(100), | ||
timestamp, | ||
)) | ||
} |
6 changes: 6 additions & 0 deletions
6
examples/gno.land/r/demo/teritori/providers/random_pusher/gno.mod
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,6 @@ | ||
module gno.land/r/demo/teritori/random_pusher | ||
|
||
require ( | ||
gno.land/p/demo/avl v0.0.0-latest | ||
gno.land/p/demo/testutils v0.0.0-latest | ||
) |
22 changes: 22 additions & 0 deletions
22
examples/gno.land/r/demo/teritori/providers/random_pusher/worx_dao.gno
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,22 @@ | ||
package random_pusher | ||
|
||
import ( | ||
"std" | ||
"gno.land/r/teritori/worx_aggregator" | ||
"math/rand" | ||
) | ||
|
||
var admin std.Address | ||
|
||
func init() { | ||
admin = std.GetOrigCaller() | ||
|
||
} | ||
|
||
var rSeed = rand.NewPCG(0, 0) | ||
|
||
func RandWorx(addr std.Address){ | ||
r := rand.New(rSeed) | ||
|
||
worx_aggregator.Push(r.IntN(25), "", addr, r.IntN(100), std.GetHeight()) | ||
} |
This file was deleted.
Oops, something went wrong.
22 changes: 22 additions & 0 deletions
22
examples/gno.land/r/demo/teritori/worx_aggregator/admin.gno
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,22 @@ | ||
package worx_aggregator | ||
|
||
import ( | ||
"std" | ||
) | ||
|
||
var adminAddr std.Address | ||
|
||
func assertIsAdmin() { | ||
if std.PrevRealm().Addr() != adminAddr { | ||
panic("restricted area") | ||
} | ||
} | ||
|
||
func setAdminAddress(address std.Address) { | ||
adminAddr = address | ||
} | ||
|
||
func SetAdminAddress(address std.Address) { | ||
assertIsAdmin() | ||
setAdminAddress(address) | ||
} |
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
Oops, something went wrong.