Skip to content

Commit

Permalink
all test are passing
Browse files Browse the repository at this point in the history
  • Loading branch information
billettc committed Nov 13, 2020
1 parent c0ad8c7 commit bbcd748
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 44 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.14

require (
github.com/GeertJohan/go.rice v1.0.0
github.com/dfuse-io/binary v0.0.0-20201112224506-51f34a8dba0b
github.com/dfuse-io/binary v0.0.0-20201113132610-5a1e246afeec
github.com/dfuse-io/logging v0.0.0-20201110202154-26697de88c79
github.com/google/go-cmp v0.4.1 // indirect
github.com/gorilla/rpc v1.2.0
Expand Down
6 changes: 6 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dfuse-io/binary v0.0.0-20201112224506-51f34a8dba0b h1:2NWveAQS+xy4wb/iTg/1X8Qr70GidmTW/bmozWUQ9Pk=
github.com/dfuse-io/binary v0.0.0-20201112224506-51f34a8dba0b/go.mod h1:GDFX6qH3BQZPWTeYaA4ZW98T94zs2skRoG3oMz/0jw0=
github.com/dfuse-io/binary v0.0.0-20201113023603-c9fa399519b4 h1:ZnobDPlS6eXDUHjsk5oxsdwn9U4nvd8EpoBLVzJafxA=
github.com/dfuse-io/binary v0.0.0-20201113023603-c9fa399519b4/go.mod h1:GDFX6qH3BQZPWTeYaA4ZW98T94zs2skRoG3oMz/0jw0=
github.com/dfuse-io/binary v0.0.0-20201113125316-ded9ef4ba4f3 h1:49mP2UMaYvSB5BUIE6NloqSlpwY0RN64lFlGT6h/CgI=
github.com/dfuse-io/binary v0.0.0-20201113125316-ded9ef4ba4f3/go.mod h1:GDFX6qH3BQZPWTeYaA4ZW98T94zs2skRoG3oMz/0jw0=
github.com/dfuse-io/binary v0.0.0-20201113132610-5a1e246afeec h1:VmIyiZuZzW1ENZyIHBwyCaj/w3rHDdfFrtSXzFeXIGg=
github.com/dfuse-io/binary v0.0.0-20201113132610-5a1e246afeec/go.mod h1:GDFX6qH3BQZPWTeYaA4ZW98T94zs2skRoG3oMz/0jw0=
github.com/dfuse-io/dauth v0.0.0-20200529171443-21c0e2d262c2/go.mod h1:tab5biQg59hbrHjaXTjaLcsP3zblx6B0I0Keu03xB44=
github.com/dfuse-io/derr v0.0.0-20200406214256-c690655246a1/go.mod h1:JW/hUKChGd6ytDtvwx4JFo57m1pnFvMxaq9WbDAb2fQ=
github.com/dfuse-io/derr v0.0.0-20200417132224-d333cfd0e9a0/go.mod h1:/DjjRCyTi/KIiI1E1hnhvfWwg+K06jo+qM4VcjHvHq4=
Expand Down
11 changes: 11 additions & 0 deletions init_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package solana

import (
"github.com/dfuse-io/logging"
"go.uber.org/zap"
)

func init() {
zlog, _ = zap.NewDevelopment()
logging.TestingOverride()
}
5 changes: 2 additions & 3 deletions logging.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,12 @@
package solana

import (
"os"

"github.com/dfuse-io/logging"
"go.uber.org/zap"
)

var traceEnabled = os.Getenv("TRACE") != ""
var traceEnabled = logging.IsTraceEnabled("solana-go", "github.com/dfuse-io/solana-go")

var zlog = zap.NewNop()

func init() {
Expand Down
1 change: 1 addition & 0 deletions serum/testdata/orderbook.hex

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions serum/testdata/orderbook_lite.hex
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
736572756d210000000000000003000000000000004400000000000000250000000000000011000000000000000100000039000000cb0892ffffffffff42070000000000003700000038000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000004050000823192ffffffffff1d070000000000005ae01b52d00a090c6dc6fce8e37a225815cff2223a99c6dfdad5aae56d3db670ec85000000000000f1635e02332667a8
37 changes: 0 additions & 37 deletions serum/types_test.go
Original file line number Diff line number Diff line change
@@ -1,53 +1,16 @@
package serum

import (
"bytes"
"encoding/hex"
"encoding/json"
"fmt"
"io/ioutil"
"testing"

bin "github.com/dfuse-io/binary"

"github.com/stretchr/testify/require"
)

func TestDecoder_DecodeSol(t *testing.T) {
hexData, err := ioutil.ReadFile("./testdata/orderbook_lite.hex")
require.NoError(t, err)

fmt.Println(hexData)

cnt, err := hex.DecodeString(string(hexData))
require.NoError(t, err)

decoder := bin.NewDecoder(cnt)
var ob *Orderbook
err = decoder.Decode(&ob)
require.NoError(t, err)

//require.Equal(t, 0, decoder.remaining())
json, err := json.MarshalIndent(ob, "", " ")
require.NoError(t, err)
fmt.Println(string(json))

fmt.Println("-------------------------------------------------------")
fmt.Println("-------------------------------------------------------")
fmt.Println("-------------------------------------------------------")

buf := new(bytes.Buffer)
encoder := bin.NewEncoder(buf)
err = encoder.Encode(ob)
require.NoError(t, err)

obHex := hex.EncodeToString(buf.Bytes())

fmt.Println("expected:", hexData)
fmt.Println("actual :", obHex)
require.Equal(t, cnt, buf.Bytes())
}

func TestDecoder_Slabs(t *testing.T) {

//zlog, _ := zap.NewDevelopment()
Expand Down
5 changes: 2 additions & 3 deletions token/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (
bin "github.com/dfuse-io/binary"
"github.com/dfuse-io/solana-go"
"github.com/dfuse-io/solana-go/rpc"
"github.com/lunixbochs/struc"
"github.com/mr-tron/base58"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
Expand All @@ -43,7 +42,7 @@ func TestAccount(t *testing.T) {
// 01000000 // is initialized, is native + padding
// 0000000000000000 // delegate amount
var out Account
err := struc.Unpack(bytes.NewReader(data), &out)
err := bin.NewDecoder(data).Decode(&out)
require.NoError(t, err)

expect := Account{
Expand All @@ -61,7 +60,7 @@ func TestAccount(t *testing.T) {
assert.JSONEq(t, string(expectJSON), string(outJSON))

buf := &bytes.Buffer{}
assert.NoError(t, struc.Pack(buf, out))
assert.NoError(t, bin.NewEncoder(buf).Encode(out))

assert.Equal(t, b58data, base58.Encode(buf.Bytes()))
}
Expand Down
4 changes: 4 additions & 0 deletions transactions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,13 @@ import (
)

func TestCompiledInstructions(t *testing.T) {
traceEnabled = true

ci := &CompiledInstruction{
ProgramIDIndex: 5,
AccountsCount: 3,
Accounts: []uint8{2, 5, 8},
DataLength: 5,
Data: Base58([]byte{1, 2, 3, 4, 5}),
}
buf := &bytes.Buffer{}
Expand Down

0 comments on commit bbcd748

Please sign in to comment.