@ -310,7 +310,7 @@ func TestGetHistoryTxs(t *testing.T) {
path := fmt . Sprintf ( "%s?limit=%d&fromItem=" , endpoint , limit )
path := fmt . Sprintf ( "%s?limit=%d&fromItem=" , endpoint , limit )
err := doGoodReqPaginated ( path , historydb . OrderAsc , & testTxsResponse { } , appendIter )
err := doGoodReqPaginated ( path , historydb . OrderAsc , & testTxsResponse { } , appendIter )
assert . NoError ( t , err )
assert . NoError ( t , err )
assertHistory TxAPI s ( t , tc . allTxs , fetchedTxs )
assertTxs ( t , tc . allTxs , fetchedTxs )
// Uncomment once tx generation for tests is fixed
// Uncomment once tx generation for tests is fixed
// // Get by ethAddr
// // Get by ethAddr
// fetchedTxs = []testTx{}
// fetchedTxs = []testTx{}
@ -321,7 +321,7 @@ func TestGetHistoryTxs(t *testing.T) {
// )
// )
// err = doGoodReqPaginated(path, historydb.OrderAsc, &testTxsResponse{}, appendIter)
// err = doGoodReqPaginated(path, historydb.OrderAsc, &testTxsResponse{}, appendIter)
// assert.NoError(t, err)
// assert.NoError(t, err)
// assertHistory TxAPI s(t, tc.usrTxs, fetchedTxs)
// assertTxs(t, tc.usrTxs, fetchedTxs)
// // Get by bjj
// // Get by bjj
// fetchedTxs = []testTx{}
// fetchedTxs = []testTx{}
// limit = 6
// limit = 6
@ -331,7 +331,7 @@ func TestGetHistoryTxs(t *testing.T) {
// )
// )
// err = doGoodReqPaginated(path, historydb.OrderAsc, &testTxsResponse{}, appendIter)
// err = doGoodReqPaginated(path, historydb.OrderAsc, &testTxsResponse{}, appendIter)
// assert.NoError(t, err)
// assert.NoError(t, err)
// assertHistory TxAPI s(t, tc.usrTxs, fetchedTxs)
// assertTxs(t, tc.usrTxs, fetchedTxs)
// Get by tokenID
// Get by tokenID
fetchedTxs = [ ] testTx { }
fetchedTxs = [ ] testTx { }
limit = 5
limit = 5
@ -348,7 +348,7 @@ func TestGetHistoryTxs(t *testing.T) {
tokenIDTxs = append ( tokenIDTxs , tc . allTxs [ i ] )
tokenIDTxs = append ( tokenIDTxs , tc . allTxs [ i ] )
}
}
}
}
assertHistory TxAPI s ( t , tokenIDTxs , fetchedTxs )
assertTxs ( t , tokenIDTxs , fetchedTxs )
// idx
// idx
fetchedTxs = [ ] testTx { }
fetchedTxs = [ ] testTx { }
limit = 4
limit = 4
@ -366,7 +366,7 @@ func TestGetHistoryTxs(t *testing.T) {
idxTxs = append ( idxTxs , tc . allTxs [ i ] )
idxTxs = append ( idxTxs , tc . allTxs [ i ] )
}
}
}
}
assertHistory TxAPI s ( t , idxTxs , fetchedTxs )
assertTxs ( t , idxTxs , fetchedTxs )
// batchNum
// batchNum
fetchedTxs = [ ] testTx { }
fetchedTxs = [ ] testTx { }
limit = 3
limit = 3
@ -384,7 +384,7 @@ func TestGetHistoryTxs(t *testing.T) {
batchNumTxs = append ( batchNumTxs , tc . allTxs [ i ] )
batchNumTxs = append ( batchNumTxs , tc . allTxs [ i ] )
}
}
}
}
assertHistory TxAPI s ( t , batchNumTxs , fetchedTxs )
assertTxs ( t , batchNumTxs , fetchedTxs )
// type
// type
txTypes := [ ] common . TxType {
txTypes := [ ] common . TxType {
// Uncomment once test gen is fixed
// Uncomment once test gen is fixed
@ -414,7 +414,7 @@ func TestGetHistoryTxs(t *testing.T) {
txTypeTxs = append ( txTypeTxs , tc . allTxs [ i ] )
txTypeTxs = append ( txTypeTxs , tc . allTxs [ i ] )
}
}
}
}
assertHistory TxAPI s ( t , txTypeTxs , fetchedTxs )
assertTxs ( t , txTypeTxs , fetchedTxs )
}
}
// Multiple filters
// Multiple filters
fetchedTxs = [ ] testTx { }
fetchedTxs = [ ] testTx { }
@ -433,7 +433,7 @@ func TestGetHistoryTxs(t *testing.T) {
}
}
}
}
}
}
assertHistory TxAPI s ( t , mixedTxs , fetchedTxs )
assertTxs ( t , mixedTxs , fetchedTxs )
// All, in reverse order
// All, in reverse order
fetchedTxs = [ ] testTx { }
fetchedTxs = [ ] testTx { }
limit = 5
limit = 5
@ -444,7 +444,7 @@ func TestGetHistoryTxs(t *testing.T) {
for i := 0 ; i < len ( tc . allTxs ) ; i ++ {
for i := 0 ; i < len ( tc . allTxs ) ; i ++ {
flipedTxs = append ( flipedTxs , tc . allTxs [ len ( tc . allTxs ) - 1 - i ] )
flipedTxs = append ( flipedTxs , tc . allTxs [ len ( tc . allTxs ) - 1 - i ] )
}
}
assertHistory TxAPI s ( t , flipedTxs , fetchedTxs )
assertTxs ( t , flipedTxs , fetchedTxs )
// 400
// 400
path = fmt . Sprintf (
path = fmt . Sprintf (
"%s?accountIndex=%s&hermezEthereumAddress=%s" ,
"%s?accountIndex=%s&hermezEthereumAddress=%s" ,
@ -474,7 +474,7 @@ func TestGetHistoryTx(t *testing.T) {
assert . NoError ( t , err )
assert . NoError ( t , err )
fetchedTxs = append ( fetchedTxs , fetchedTx )
fetchedTxs = append ( fetchedTxs , fetchedTx )
}
}
assertHistory TxAPI s ( t , tc . allTxs , fetchedTxs )
assertTxs ( t , tc . allTxs , fetchedTxs )
// 400
// 400
err := doBadReq ( "GET" , endpoint + "0x001" , nil , 400 )
err := doBadReq ( "GET" , endpoint + "0x001" , nil , 400 )
assert . NoError ( t , err )
assert . NoError ( t , err )
@ -483,7 +483,7 @@ func TestGetHistoryTx(t *testing.T) {
assert . NoError ( t , err )
assert . NoError ( t , err )
}
}
func assertHistory TxAPI s ( t * testing . T , expected , actual [ ] testTx ) {
func assertTxs ( t * testing . T , expected , actual [ ] testTx ) {
require . Equal ( t , len ( expected ) , len ( actual ) )
require . Equal ( t , len ( expected ) , len ( actual ) )
for i := 0 ; i < len ( actual ) ; i ++ { //nolint len(actual) won't change within the loop
for i := 0 ; i < len ( actual ) ; i ++ { //nolint len(actual) won't change within the loop
actual [ i ] . ItemID = 0
actual [ i ] . ItemID = 0