package liquidity import ( "testing" "github.com/stretchr/testify/require" ) // TestValidateRestrictions tests validating client restrictions against a set // of server restrictions. func TestValidateRestrictions(t *testing.T) { tests := []struct { name string client *Restrictions server *Restrictions err error }{ { name: "client invalid", client: &Restrictions{ Minimum: 100, Maximum: 1, }, server: testRestrictions, err: ErrMinimumExceedsMaximumAmt, }, { name: "maximum exceeds server", client: &Restrictions{ Maximum: 2000, }, server: &Restrictions{ Minimum: 1000, Maximum: 1500, }, err: ErrMaxExceedsServer, }, { name: "minimum less than server", client: &Restrictions{ Minimum: 500, }, server: &Restrictions{ Minimum: 1000, Maximum: 1500, }, err: ErrMinLessThanServer, }, } for _, testCase := range tests { testCase := testCase t.Run(testCase.name, func(t *testing.T) { err := validateRestrictions( testCase.server, testCase.client, ) require.Equal(t, testCase.err, err) }) } }