Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
donovanhide committed Apr 12, 2022
1 parent f6ebde1 commit a984924
Show file tree
Hide file tree
Showing 13 changed files with 25 additions and 29 deletions.
2 changes: 1 addition & 1 deletion config/action_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ func TestParse(t *testing.T) {
if err := actions.Prepare(); err != nil {
t.Fatalf("prepare: %v", err)
}
t.Log(actions)
// t.Log(actions)
}
2 changes: 1 addition & 1 deletion data/codec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ var _ = Suite(&CodecSuite{})

func dump(test internal.TestData, v interface{}) CommentInterface {
out, _ := json.Marshal(v)
return Commentf("Test: %s\nJSON:%s\n", test.Description, string(out))
return Commentf("Test: %s\n Object: %v\n JSON: %s\n", test.Description, v, string(out))
}

func (s *CodecSuite) TestParseTransactions(c *C) {
Expand Down
2 changes: 1 addition & 1 deletion data/encoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ func getFields(v *reflect.Value, depth int) fieldSlice {
if f.Kind() == reflect.Ptr {
f = f.Elem()
}
if !f.IsValid() || !f.CanInterface() || (f.Kind() == reflect.Slice && f.Len() == 0) {
if !f.IsValid() || (f.Kind() == reflect.Slice && f.Len() == 0) {
continue
}
switch encoding.typ {
Expand Down
18 changes: 9 additions & 9 deletions data/ledger.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package data

type LedgerHeader struct {
LedgerSequence uint32 `json:"ledger_index,string"`
TotalXRP uint64 `json:"total_coins,string"`
PreviousLedger Hash256 `json:"parent_hash"`
TransactionHash Hash256 `json:"transaction_hash"`
StateHash Hash256 `json:"account_hash"`
ParentCloseTime RippleTime `json:"parent_close_time"`
CloseTime RippleTime `json:"close_time"`
CloseResolution uint8 `json:"close_time_resolution"`
CloseFlags uint8 `json:"close_flags"`
LedgerSequence uint32 `json:"ledger_index,string"`
TotalXRP uint64 `json:"total_coins,string"`
PreviousLedger Hash256 `json:"parent_hash"`
TransactionHash Hash256 `json:"transaction_hash"`
StateHash Hash256 `json:"account_hash"`
ParentCloseTime *RippleTime `json:"parent_close_time,omitempty"`
CloseTime *RippleTime `json:"close_time"`
CloseResolution uint8 `json:"close_time_resolution"`
CloseFlags uint8 `json:"close_flags,omitempty"`
}

type Ledger struct {
Expand Down
2 changes: 1 addition & 1 deletion data/testdata/ledger_6000000.json
Original file line number Diff line number Diff line change
Expand Up @@ -3972,7 +3972,7 @@
],
"account_hash": "2C23D15B6B549123FB351E4B5CDE81C564318EB845449CD43C3EA7953C4DB452",
"close_time": 410424200,
"close_time_human": "2013-Jan-02 06:43:20",
"close_time_human": "2013-Jan-02 06:43:20 UTC",
"close_time_resolution": 10,
"closed": true,
"hash": "E6DB7365949BF9814D76BCC730B01818EB9136A89DB224F3F9F5AAE4569D758E",
Expand Down
3 changes: 1 addition & 2 deletions tools/book/book.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ Examples:
book XRP USD/rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B
Show all offers for where the taker pays USD/rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B and the taker gets XRP
Options:
`
Options:`

var (
host = flag.String("host", "wss://s1.ripple.com:443", "websockets host")
Expand Down
3 changes: 1 addition & 2 deletions tools/explain/explain.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ explain 955A4C0B7C66FC97EA4C72634CDCDBF50BB17AAA647EC6C8C592788E5B95173C
explain -
Explain binary transactions received through stdin
Options:
`
Options:`

var argumentRegex = regexp.MustCompile(`(^[0-9a-fA-F]{64}$)|(^\d+$)|(^[r][a-km-zA-HJ-NP-Z0-9]{26,34}$)|(-)`)

Expand Down
3 changes: 1 addition & 2 deletions tools/lines/lines.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ Examples:
lines rBxy23n7ZFbUpS699rFVj1V9ZVhAq6EGwC
Show all trust lines for account rBxy23n7ZFbUpS699rFVj1V9ZVhAq6EGwC
Options:
`
Options:`

var (
host = flag.String("host", "wss://s1.ripple.com:443", "websockets host")
Expand Down
3 changes: 1 addition & 2 deletions tools/offers/offers.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ Examples:
offers rBxy23n7ZFbUpS699rFVj1V9ZVhAq6EGwC
Show all offers for account rBxy23n7ZFbUpS699rFVj1V9ZVhAq6EGwC
Options:
`
Options:`

var (
host = flag.String("host", "wss://s1.ripple.com:443", "websockets host")
Expand Down
8 changes: 4 additions & 4 deletions websockets/commands_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func (s *MessagesSuite) TestLedgerResponse(c *C) {
// Result fields
c.Assert(msg.Result.Ledger.LedgerSequence, Equals, uint32(6917762))
c.Assert(msg.Result.Ledger.Accepted, Equals, true)
c.Assert(msg.Result.Ledger.CloseTime.String(), Equals, "2014-May-30 13:11:50")
c.Assert(msg.Result.Ledger.CloseTime.String(), Equals, "2014-May-30 13:11:50 UTC")
c.Assert(msg.Result.Ledger.Closed, Equals, true)
c.Assert(msg.Result.Ledger.Hash.String(), Equals, "0C5C5B39EA40D40ACA6EB47E50B2B85FD516D1A2BA67BA3E050349D3EF3632A4")
c.Assert(msg.Result.Ledger.PreviousLedger.String(), Equals, "F8F0363803C30E659AA24D6A62A6512BA24BEA5AC52A29731ABA1E2D80796E8B")
Expand All @@ -64,7 +64,7 @@ func (s *MessagesSuite) TestLedgerHeaderResponse(c *C) {
c.Assert(msg.Result.LedgerSequence, Equals, uint32(32570))
c.Assert(msg.Result.Ledger.LedgerSequence, Equals, uint32(32570))
c.Assert(msg.Result.Ledger.Accepted, Equals, true)
c.Assert(msg.Result.Ledger.CloseTime.String(), Equals, "2013-Jan-01 03:21:10")
c.Assert(msg.Result.Ledger.CloseTime.String(), Equals, "2013-Jan-01 03:21:10 UTC")
c.Assert(msg.Result.Ledger.Closed, Equals, true)
c.Assert(msg.Result.Ledger.Hash.String(), Equals, "4109C6F2045FC7EFF4CDE8F9905D19C28820D86304080FF886B299F0206E42B5")
c.Assert(msg.Result.Ledger.PreviousLedger.String(), Equals, "60A01EBF11537D8394EA1235253293508BDA7131D5F8710EFE9413AA129653A2")
Expand All @@ -83,7 +83,7 @@ func (s *MessagesSuite) TestTxResponse(c *C) {
c.Assert(msg.Type, Equals, "response")

// Result fields
c.Assert(msg.Result.Date.String(), Equals, "2014-May-30 13:11:50")
c.Assert(msg.Result.Date.String(), Equals, "2014-May-30 13:11:50 UTC")
c.Assert(msg.Result.Validated, Equals, true)
c.Assert(msg.Result.MetaData.AffectedNodes, HasLen, 4)
c.Assert(msg.Result.MetaData.TransactionResult.String(), Equals, "tesSUCCESS")
Expand All @@ -107,7 +107,7 @@ func (s *MessagesSuite) TestAccountTxResponse(c *C) {
c.Assert(msg.Type, Equals, "response")

c.Assert(len(msg.Result.Transactions), Equals, 2)
c.Assert(msg.Result.Transactions[1].Date.String(), Equals, "2014-Jun-19 14:14:40")
c.Assert(msg.Result.Transactions[1].Date.String(), Equals, "2014-Jun-19 14:14:40 UTC")
offer := msg.Result.Transactions[1].Transaction.(*data.OfferCreate)
c.Assert(offer.TakerPays.String(), Equals, "0.034800328/BTC/rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B")
}
Expand Down
4 changes: 2 additions & 2 deletions websockets/subscribe_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func (s *MessagesSuite) TestLedgerSubscribeResponse(c *C) {
c.Assert(msg.Result.FeeRef, Equals, uint64(10))
c.Assert(msg.Result.LedgerSequence, Equals, uint32(6959228))
c.Assert(msg.Result.LedgerHash.String(), Equals, "E23869F043A46C2735BCA40781A674C5F24460BAC26C6B7475550493A9180200")
c.Assert(msg.Result.LedgerTime.String(), Equals, "2014-Jun-01 20:56:40")
c.Assert(msg.Result.LedgerTime.String(), Equals, "2014-Jun-01 20:56:40 UTC")
c.Assert(msg.Result.ReserveBase, Equals, uint64(20000000))
c.Assert(msg.Result.ReserveIncrement, Equals, uint64(5000000))
c.Assert(msg.Result.ValidatedLedgers, Equals, "32570-6959228")
Expand All @@ -38,7 +38,7 @@ func (s *MessagesSuite) TestLedgerStreamMsg(c *C) {
c.Assert(msg.FeeRef, Equals, uint64(10))
c.Assert(msg.LedgerSequence, Equals, uint32(6959229))
c.Assert(msg.LedgerHash.String(), Equals, "21EB30937A47EA6B71B63183806FFE9308CCB786137AA00FFB32A7094C6426FA")
c.Assert(msg.LedgerTime.String(), Equals, "2014-Jun-01 20:56:40")
c.Assert(msg.LedgerTime.String(), Equals, "2014-Jun-01 20:56:40 UTC")
c.Assert(msg.ReserveBase, Equals, uint64(20000000))
c.Assert(msg.ReserveIncrement, Equals, uint64(5000000))
c.Assert(msg.ValidatedLedgers, Equals, "32570-6959229")
Expand Down
2 changes: 1 addition & 1 deletion websockets/testdata/ledger.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"accepted": true,
"account_hash": "46D3E36FE845B9A18293F4C0F134D7DAFB06D4D9A1C7E4CB03F8B293CCA45FA0",
"close_time": 454770710,
"close_time_human": "2014-May-30 13:11:50",
"close_time_human": "2014-May-30 13:11:50 UTC",
"close_time_resolution": 10,
"closed": true,
"hash": "0C5C5B39EA40D40ACA6EB47E50B2B85FD516D1A2BA67BA3E050349D3EF3632A4",
Expand Down
2 changes: 1 addition & 1 deletion websockets/testdata/ledger_header.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"accepted": true,
"account_hash": "3806AF8F22037DE598D30D38C8861FADF391171D26F7DE34ACFA038996EA6BEB",
"close_time": 410325670,
"close_time_human": "2013-Jan-01 03:21:10",
"close_time_human": "2013-Jan-01 03:21:10 UTC",
"close_time_resolution": 10,
"closed": true,
"hash": "4109C6F2045FC7EFF4CDE8F9905D19C28820D86304080FF886B299F0206E42B5",
Expand Down

0 comments on commit a984924

Please sign in to comment.