Skip to content

Commit

Permalink
fix(compat): fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanswrt committed Mar 25, 2021
1 parent 15de03c commit 265b64b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 43 deletions.
20 changes: 1 addition & 19 deletions compat/v0/compat_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"database/sql"
"encoding/base64"
"encoding/hex"
"encoding/json"
"fmt"
"math/big"
"os"
Expand All @@ -23,7 +22,6 @@ import (
"github.com/renproject/darknode/tx"
"github.com/renproject/id"
v0 "github.com/renproject/lightnode/compat/v0"
v2 "github.com/renproject/lightnode/compat/v2"
"github.com/renproject/lightnode/db"
"github.com/renproject/lightnode/testutils"
"github.com/renproject/multichain"
Expand Down Expand Up @@ -100,23 +98,7 @@ var _ = Describe("Compat V0", func() {
})

It("should convert a QueryState response into a QueryFees response", func() {
mockState := testutils.MockQueryBlockStateResponse()

raw, err := json.Marshal(mockState)
Expect(err).ToNot(HaveOccurred())

var resp v2.QueryBlockStateJSON
json.Unmarshal(raw, &resp)
Expect(err).ToNot(HaveOccurred())
shardsResponse, err := v0.QueryFeesResponseFromState(
map[string]v2.UTXOState{
"BTC": resp.State.BTC,
"ZEC": resp.State.ZEC,
"BCH": resp.State.BCH,
"DGB": resp.State.DGB,
"DOGE": resp.State.DOGE,
},
)
shardsResponse, err := v0.QueryFeesResponseFromState(testutils.MockEngineState())

Expect(err).ShouldNot(HaveOccurred())
Expect(shardsResponse.Btc.Lock.Int).Should(Equal(big.NewInt(6)))
Expand Down
25 changes: 1 addition & 24 deletions compat/v1/compat_test.go
Original file line number Diff line number Diff line change
@@ -1,40 +1,17 @@
package v1_test

import (
"encoding/json"

. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"

v1 "github.com/renproject/lightnode/compat/v1"
v2 "github.com/renproject/lightnode/compat/v2"
"github.com/renproject/lightnode/testutils"
)

var _ = Describe("Compat V0", func() {
It("should convert a QueryBlockState response into a QueryState response", func() {
mockState := testutils.MockQueryBlockStateResponse()

raw, err := json.Marshal(mockState)
Expect(err).ToNot(HaveOccurred())

var resp v2.QueryBlockStateJSON
json.Unmarshal(raw, &resp)
Expect(err).ToNot(HaveOccurred())
stateResponse, err := v1.QueryStateResponseFromState(testutils.MockEngineState())

stateResponse, err := v1.QueryStateResponseFromState(
map[string]v2.UTXOState{
"BTC": resp.State.BTC,
"ZEC": resp.State.ZEC,
"BCH": resp.State.BCH,
"DGB": resp.State.DGB,
"DOGE": resp.State.DOGE,
},
map[string]v2.AccountState{
"LUNA": resp.State.LUNA,
"FIL": resp.State.FIL,
},
)
Expect(err).ShouldNot(HaveOccurred())
Expect(stateResponse.Bitcoin.Gaslimit).Should(Equal("3"))
})
Expand Down

0 comments on commit 265b64b

Please sign in to comment.