@@ -11,37 +11,36 @@ import (
1111)
1212
1313func TestValidateAddressFailure (t * testing.T ) {
14+ // Set up cache and ensure cleanup after test
1415 cache , cleanup := withCache (t )
15- defer cleanup ( )
16+ t . Cleanup ( cleanup )
1617
17- // create contract
18+ // Create contract
1819 wasm , err := os .ReadFile ("../../testdata/hackatom.wasm" )
1920 require .NoError (t , err )
2021 checksum , err := StoreCode (cache , wasm , true )
2122 require .NoError (t , err )
2223
23- gasMeter := NewMockGasMeter (TESTING_GAS_LIMIT )
24- // instantiate it with this store
24+ gasMeter := NewMockGasMeter (testingGasLimit )
2525 store := NewLookup (gasMeter )
2626 api := NewMockAPI ()
2727 querier := DefaultQuerier (MOCK_CONTRACT_ADDR , types.Array [types.Coin ]{types .NewCoin (100 , "ATOM" )})
2828 env := MockEnvBin (t )
2929 info := MockInfoBin (t , "creator" )
3030
31- // if the human address is larger than 32 bytes, this will lead to an error in the go side
31+ // If the human address is larger than 32 bytes, it triggers an error in address validation
3232 longName := "long123456789012345678901234567890long"
33- msg := []byte (`{"verifier": "` + longName + `", "beneficiary": "bob"}` )
33+ msg := []byte (`{"verifier":"` + longName + `","beneficiary":"bob"}` )
3434
35- // make sure the call doesn't error, but we get a JSON-encoded error result from ContractResult
3635 igasMeter := types .GasMeter (gasMeter )
37- res , _ , err := Instantiate (cache , checksum , env , info , msg , & igasMeter , store , api , & querier , TESTING_GAS_LIMIT , TESTING_PRINT_DEBUG )
36+ res , _ , err := Instantiate (cache , checksum , env , info , msg , & igasMeter , store , api , & querier , testingGasLimit , testingPrintDebug )
3837 require .NoError (t , err )
38+
3939 var result types.ContractResult
4040 err = json .Unmarshal (res , & result )
4141 require .NoError (t , err )
4242
43- // ensure the error message is what we expect
43+ // The contract call succeeds at the VM level but returns a JSON error inside ContractResult
4444 require .Nil (t , result .Ok )
45- // with this error
4645 require .Equal (t , "Generic error: addr_validate errored: human encoding too long" , result .Err )
4746}
0 commit comments