Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
mconcat committed Mar 8, 2021
1 parent f71fafc commit adf3454
Show file tree
Hide file tree
Showing 9 changed files with 772 additions and 217 deletions.
35 changes: 5 additions & 30 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,9 @@ module github.com/confio/ics23
go 1.14

require (
github.com/allegro/bigcache v1.2.1 // indirect
github.com/aristanetworks/goarista v0.0.0-20190712234253-ed1100a1c015 // indirect
github.com/btcsuite/btcd v0.21.0-beta // indirect
github.com/confio/ics23/go v0.0.0-20200804135649-a9fbc744ca3d // indirect
github.com/deckarep/golang-set v1.7.1 // indirect
github.com/edsrzf/mmap-go v1.0.0 // indirect
github.com/elastic/gosigar v0.10.4 // indirect
github.com/ethereum/go-ethereum v1.9.1
github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff // indirect
github.com/golang/protobuf v1.3.2 // indirect
github.com/gorilla/websocket v1.4.0 // indirect
github.com/hashicorp/golang-lru v0.5.3 // indirect
github.com/huin/goupnp v1.0.0 // indirect
github.com/jackpal/go-nat-pmp v1.0.1 // indirect
github.com/karalabe/usb v0.0.0-20190703133951-9be757f914c0 // indirect
github.com/mattn/go-runewidth v0.0.4 // indirect
github.com/olekukonko/tablewriter v0.0.1 // indirect
github.com/pborman/uuid v1.2.0 // indirect
github.com/prometheus/tsdb v0.10.0 // indirect
github.com/rjeczalik/notify v0.9.2 // indirect
github.com/rs/cors v1.6.0 // indirect
github.com/status-im/keycard-go v0.0.0-20190424133014-d95853db0f48 // indirect
github.com/steakknife/bloomfilter v0.0.0-20180922174646-6819c0d2a570 // indirect
github.com/steakknife/hamming v0.0.0-20180906055917-c99c65617cd3 // indirect
github.com/stretchr/testify v1.3.0
github.com/syndtr/goleveldb v1.0.0 // indirect
github.com/tyler-smith/go-bip39 v1.0.0 // indirect
github.com/wsddn/go-ecdh v0.0.0-20161211032359-48726bab9208 // indirect
golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect
github.com/ethereum/go-ethereum v1.10.0
github.com/gogo/protobuf v1.3.2
github.com/pkg/errors v0.8.1
github.com/stretchr/testify v1.7.0
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9
)
544 changes: 535 additions & 9 deletions go.sum

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion go/ops_test_data.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package proofs
package ics23

import (
"encoding/hex"
Expand Down
10 changes: 5 additions & 5 deletions go/proof_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ func TestCheckLeaf(t *testing.T) {
cases := CheckLeafTestData()
for name, tc := range cases {
t.Run(name, func(t *testing.T) {
err := tc.leaf.CheckAgainstSpec(&ProofSpec{LeafSpec: tc.spec})
if tc.isErr && err == nil {
err := tc.Leaf.CheckAgainstSpec(&ProofSpec{LeafSpec: tc.Spec})
if tc.IsErr && err == nil {
t.Fatal("Expected error, but got nil")
} else if !tc.IsErr && err != nil {
t.Fatalf("Unexpected error: %v", err)
Expand Down Expand Up @@ -208,10 +208,10 @@ func TestCheckAgainstSpec(t *testing.T) {

for name, tc := range cases {
t.Run(name, func(t *testing.T) {
err := tc.Proof.CheckAgainstSpec(tc.Spec)
if tc.IsErr && err == nil {
err := tc.proof.CheckAgainstSpec(tc.spec)
if tc.isErr && err == nil {
t.Fatal("Expected error, but got nil")
} else if !tc.IsErr && err != nil {
} else if !tc.isErr && err != nil {
t.Fatalf("Unexpected error: %v", err)
}
})
Expand Down
2 changes: 1 addition & 1 deletion go/proof_test_data.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package proofs
package ics23

type ExistenceProofTestStruct struct {
Proof *ExistenceProof
Expand Down
21 changes: 8 additions & 13 deletions sol/ics23.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
package ics23

import (

proofs "github.com/confio/proofs/go"
ics23 "github.com/confio/ics23/go"
)

type LeafOp = Struct0
type InnerOp = Struct1
type ExistenceProof = Struct2

func LeafOpToABI(op *proofs.LeafOp) LeafOp {
return LeafOp{
func LeafOpToABI(op *ics23.LeafOp) ICS23LeafOp {
return ICS23LeafOp{
Hash: uint8(op.Hash),
PrehashKey: uint8(op.PrehashKey),
PrehashValue: uint8(op.PrehashValue),
Expand All @@ -19,20 +14,20 @@ func LeafOpToABI(op *proofs.LeafOp) LeafOp {
}
}

func InnerOpToABI(op *proofs.InnerOp) InnerOp {
return InnerOp{
func InnerOpToABI(op *ics23.InnerOp) ICS23InnerOp {
return ICS23InnerOp{
Hash: uint8(op.Hash),
Prefix: op.Prefix,
Suffix: op.Suffix,
}
}

func ExistenceProofToABI(op *proofs.ExistenceProof) ExistenceProof {
path := make([]InnerOp, len(op.Path))
func ExistenceProofToABI(op *ics23.ExistenceProof) ICS23ExistenceProof {
path := make([]ICS23InnerOp, len(op.Path))
for i, op := range op.Path {
path[i] = InnerOpToABI(op)
}
return Struct2{
return ICS23ExistenceProof{
Key: op.Key,
Value: op.Value,
Leaf: LeafOpToABI(op.Leaf),
Expand Down
2 changes: 1 addition & 1 deletion sol/ics23.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.5.3;
pragma solidity >=0.8.0;

pragma experimental ABIEncoderV2;

Expand Down
367 changes: 213 additions & 154 deletions sol/ics23_contract.go

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions sol/proofs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ package ics23
import (
"testing"

proofs "github.com/confio/proofs/go"
ics23 "github.com/confio/ics23/go"
"github.com/stretchr/testify/require"
)

func TestExistenceProof(t *testing.T) {
session := Initialize(t)

cases := proofs.ExistenceProofTestData()
cases := ics23.ExistenceProofTestData()

for name, tc := range cases {
if tc.Proof.Leaf == nil {
Expand All @@ -34,7 +34,7 @@ func TestExistenceProof(t *testing.T) {
func TestCheckAgainstSpec(t *testing.T) {
session := Initialize(t)

cases := proofs.CheckAgainstSpecTestData()
cases := ics23.CheckAgainstSpecTestData()

for name, tc := range cases {
if tc.Proof.Leaf == nil {
Expand Down

0 comments on commit adf3454

Please sign in to comment.