// Test POST APIs with completely random payload
Test POST APIs with completely random payload
// Test POST APIs with completely random payload
func TestPostPayloadRandom(t *testing.T) {
	gateway := New()
	gateway.setup()
	tests := []struct {
		url string
	}{
		{
			url: "/tx/send",
		},
	}
	for _, tc := range tests {
		tc := tc
		t.Run(tc.url, func(t *testing.T) {
			f := func(random1 [][]byte, random2 [][]byte) bool {
				var payload []byte
				for i := range random1 {
					payload = append(payload, random1[i]...)
				}
				for i := range random2 {
					payload = append(payload, random2[i]...)
				}
				request := httptest.NewRequest("POST", "http://localhost"+tc.url, bytes.NewReader(payload))
				res, err := serve(gateway.router, request)
				if !assert.NoError(t, err) || !assert.NotNil(t, res) {
					return false
				}
				defer func() {
					_ = res.Body.Close()
				}()
				assert.NotEmpty(t, res.StatusCode)
				return true
			}
			if err := quick.Check(f, &quick.Config{
				MaxCountScale: 10,
			}); err != nil {
				t.Error(err)
			}
		})
	}
}
func TestPostPayloadRandom ( t * testing . T ) { gateway := New ( ) gateway . setup ( ) tests := [ ] struct { url string } { { url : " " , } , } for _ , tc := range tests { tc := tc t . Run ( tc . url , func ( t * testing . T ) { f := func ( random1 [ ] [ ] byte , random2 [ ] [ ] byte ) bool { var payload [ ] byte for i := range random1 { payload = append ( payload , random1 [ i ] ... ) } for i := range random2 { payload = append ( payload , random2 [ i ] ... ) } request := httptest . NewRequest ( " " , " " + tc . url , bytes . NewReader ( payload ) ) res , err := serve ( gateway . router , request ) if ! assert . NoError ( t , err ) || ! assert . NotNil ( t , res ) { return false } defer func ( ) { _ = res . Body . Close ( ) } ( ) assert . NotEmpty ( t , res . StatusCode ) return true } if err := quick . Check ( f , & quick . Config { MaxCountScale : 10 , } ) ; err != nil { t . Error ( err ) } } ) } }
Test POST APIs with completely random payload
Test POST APIs with completely random payload