Skip to content

Commit e4bae28

Browse files
author
Tural Devrishev
committed
compiler: add contract example to measure coverage
Signed-off-by: Tural Devrishev <tural@nspcc.ru>
1 parent fcc2a9a commit e4bae28

4 files changed

Lines changed: 23 additions & 0 deletions

File tree

pkg/compiler/contract/contract.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package contract
2+
3+
func MyEven(n int) bool {
4+
if n%2 == 0 {
5+
return true
6+
}
7+
return false
8+
}

pkg/compiler/contract/contract.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
name: "contract example"

pkg/compiler/contract/cover.out

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
mode: set
2+
/home/turalchik/repositories/neo-go/pkg/compiler/contract/contract.go:5.3,5.14 1 0
3+
/home/turalchik/repositories/neo-go/pkg/compiler/contract/contract.go:7.2,7.14 1 0

pkg/compiler/interop_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -799,3 +799,14 @@ func Main() int {
799799

800800
c.Invoke(t, big.NewInt(3), "main")
801801
}
802+
803+
func TestSome(t *testing.T) {
804+
bc, acc := chain.NewSingle(t)
805+
e := neotest.NewExecutor(t, bc, acc, acc)
806+
807+
ctr := neotest.CompileFile(t, e.CommitteeHash, "./contract/contract.go", "./contract/contract.yml")
808+
e.DeployContract(t, ctr, nil)
809+
c := e.CommitteeInvoker(ctr.Hash)
810+
811+
c.Invoke(t, true, "myEven", 0)
812+
}

0 commit comments

Comments
 (0)