github.com/MetalBlockchain/subnet-evm@v0.4.9/accounts/abi/bind/bind_precompile_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 bind 28 29 import ( 30 "testing" 31 ) 32 33 var bindFailedTests = []struct { 34 name string 35 contract string 36 bytecode []string 37 abi []string 38 errorMsg string 39 fsigs []map[string]string 40 libs map[string]string 41 aliases map[string]string 42 types []string 43 }{ 44 { 45 `AnonOutputChecker`, ``, 46 []string{``}, 47 []string{` 48 [ 49 {"type":"function","name":"anonOutput","constant":true,"inputs":[],"outputs":[{"name":"","type":"string"}]} 50 ] 51 `}, 52 "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", 53 nil, 54 nil, 55 nil, 56 nil, 57 }, 58 59 { 60 `AnonOutputsChecker`, ``, 61 []string{``}, 62 []string{` 63 [ 64 {"type":"function","name":"anonOutputs","constant":true,"inputs":[],"outputs":[{"name":"","type":"string"},{"name":"","type":"string"}]} 65 ] 66 `}, 67 "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", 68 nil, 69 nil, 70 nil, 71 nil, 72 }, 73 74 { 75 `MixedOutputsChecker`, ``, 76 []string{``}, 77 []string{` 78 [ 79 {"type":"function","name":"mixedOutputs","constant":true,"inputs":[],"outputs":[{"name":"","type":"string"},{"name":"str","type":"string"}]} 80 ] 81 `}, 82 "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", 83 nil, 84 nil, 85 nil, 86 nil, 87 }, 88 } 89 90 func TestPrecompileBindings(t *testing.T) { 91 golangBindingsFailure(t) 92 } 93 94 func golangBindingsFailure(t *testing.T) { 95 // Generate the test suite for all the contracts 96 for i, tt := range bindFailedTests { 97 t.Run(tt.name, func(t *testing.T) { 98 // Generate the binding 99 _, err := Bind([]string{tt.name}, tt.abi, tt.bytecode, tt.fsigs, "bindtest", LangGo, tt.libs, tt.aliases, true) 100 if err == nil { 101 t.Fatalf("test %d: no error occurred but was expected", i) 102 } 103 104 if tt.errorMsg != err.Error() { 105 t.Fatalf("test %d: expected Err %s but got actual Err: %s", i, tt.errorMsg, err.Error()) 106 } 107 }) 108 } 109 }