github.com/cgcardona/r-subnet-evm@v0.1.5/accounts/abi/bind/precompilebind/precompile_bind_test.go (about) 1 // (c) 2019-2020, Ava Labs, Inc. 2 // 3 // This file is a derived work, based on the go-ethereum library whose original 4 // notices appear below. 5 // 6 // It is distributed under a license compatible with the licensing terms of the 7 // original code from which it is derived. 8 // 9 // Much love to the original authors for their work. 10 // ********** 11 // Copyright 2016 The go-ethereum Authors 12 // This file is part of the go-ethereum library. 13 // 14 // The go-ethereum library is free software: you can redistribute it and/or modify 15 // it under the terms of the GNU Lesser General Public License as published by 16 // the Free Software Foundation, either version 3 of the License, or 17 // (at your option) any later version. 18 // 19 // The go-ethereum library is distributed in the hope that it will be useful, 20 // but WITHOUT ANY WARRANTY; without even the implied warranty of 21 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 // GNU Lesser General Public License for more details. 23 // 24 // You should have received a copy of the GNU Lesser General Public License 25 // along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>. 26 27 package precompilebind 28 29 import ( 30 "testing" 31 32 "github.com/cgcardona/r-subnet-evm/accounts/abi/bind" 33 "github.com/stretchr/testify/require" 34 ) 35 36 var bindFailedTests = []struct { 37 name string 38 contract string 39 bytecode []string 40 abi []string 41 errorMsg string 42 fsigs []map[string]string 43 libs map[string]string 44 aliases map[string]string 45 types []string 46 }{ 47 { 48 `AnonOutputChecker`, ``, 49 []string{``}, 50 []string{` 51 [ 52 {"type":"function","name":"anonOutput","constant":true,"inputs":[],"outputs":[{"name":"","type":"string"}]} 53 ] 54 `}, 55 "ABI outputs for anonOutput require a name to generate the precompile binding, re-generate the ABI from a Solidity source file with all named outputs", 56 nil, 57 nil, 58 nil, 59 nil, 60 }, 61 62 { 63 `AnonOutputsChecker`, ``, 64 []string{``}, 65 []string{` 66 [ 67 {"type":"function","name":"anonOutputs","constant":true,"inputs":[],"outputs":[{"name":"","type":"string"},{"name":"","type":"string"}]} 68 ] 69 `}, 70 "ABI outputs for anonOutputs require a name to generate the precompile binding, re-generate the ABI from a Solidity source file with all named outputs", 71 nil, 72 nil, 73 nil, 74 nil, 75 }, 76 77 { 78 `MixedOutputsChecker`, ``, 79 []string{``}, 80 []string{` 81 [ 82 {"type":"function","name":"mixedOutputs","constant":true,"inputs":[],"outputs":[{"name":"","type":"string"},{"name":"str","type":"string"}]} 83 ] 84 `}, 85 "ABI outputs for mixedOutputs require a name to generate the precompile binding, re-generate the ABI from a Solidity source file with all named outputs", 86 nil, 87 nil, 88 nil, 89 nil, 90 }, 91 } 92 93 func TestPrecompileBindings(t *testing.T) { 94 golangBindingsFailure(t) 95 } 96 97 func golangBindingsFailure(t *testing.T) { 98 // Generate the test suite for all the contracts 99 for i, tt := range bindFailedTests { 100 t.Run(tt.name, func(t *testing.T) { 101 // Generate the binding 102 _, err := PrecompileBind([]string{tt.name}, tt.abi, tt.bytecode, tt.fsigs, "bindtest", bind.LangGo, tt.libs, tt.aliases, "", true) 103 if err == nil { 104 t.Fatalf("test %d: no error occurred but was expected", i) 105 } 106 require.ErrorContains(t, err, tt.errorMsg) 107 }) 108 } 109 }