@@ -4,11 +4,14 @@ import (
44 "testing"
55
66 "github.com/Masterminds/semver/v3"
7- "github.com/smartcontractkit/chainlink-deployments-framework/deployment"
87 "github.com/stretchr/testify/assert"
8+ "github.com/stretchr/testify/require"
9+
10+ "github.com/smartcontractkit/chainlink-deployments-framework/deployment"
911)
1012
1113func TestEnvironmentEVMRegistry_GetABIByAddress (t * testing.T ) {
14+ t .Parallel ()
1215 typeAndVersion := deployment.TypeAndVersion {
1316 Type : deployment .ContractType ("test" ),
1417 Version : * semver .MustParse ("1.0.0" ),
@@ -26,23 +29,25 @@ func TestEnvironmentEVMRegistry_GetABIByAddress(t *testing.T) {
2629 }
2730
2831 abiObj , abiStr , err := registry .GetABIByAddress (1 , "0xabc123" )
29- assert .NoError (t , err )
32+ require .NoError (t , err )
3033 assert .NotNil (t , abiObj )
31- assert .Equal (t , `[{"type":"function","name":"test","inputs":[]}]` , abiStr )
34+ assert .JSONEq (t , `[{"type":"function","name":"test","inputs":[]}]` , abiStr )
3235}
3336
3437func TestEnvironmentEVMRegistry_GetABIByAddress_ChainNotFound (t * testing.T ) {
38+ t .Parallel ()
3539 registry := & environmentEVMRegistry {
3640 abiRegistry : map [string ]string {},
3741 addressesByChain : map [uint64 ]map [string ]deployment.TypeAndVersion {},
3842 }
3943
4044 _ , _ , err := registry .GetABIByAddress (999 , "0xabc123" )
41- assert .Error (t , err )
45+ require .Error (t , err )
4246 assert .Contains (t , err .Error (), "no addresses found for chain selector" )
4347}
4448
4549func TestEnvironmentEVMRegistry_GetABIByAddress_AddressNotFound (t * testing.T ) {
50+ t .Parallel ()
4651 registry := & environmentEVMRegistry {
4752 abiRegistry : map [string ]string {},
4853 addressesByChain : map [uint64 ]map [string ]deployment.TypeAndVersion {
@@ -51,11 +56,12 @@ func TestEnvironmentEVMRegistry_GetABIByAddress_AddressNotFound(t *testing.T) {
5156 }
5257
5358 _ , _ , err := registry .GetABIByAddress (1 , "0xabc123" )
54- assert .Error (t , err )
59+ require .Error (t , err )
5560 assert .Contains (t , err .Error (), "address 0xabc123 not found" )
5661}
5762
5863func TestEnvironmentEVMRegistry_GetABIByType (t * testing.T ) {
64+ t .Parallel ()
5965 typeAndVersion := deployment.TypeAndVersion {
6066 Type : deployment .ContractType ("test" ),
6167 Version : * semver .MustParse ("1.0.0" ),
@@ -68,12 +74,13 @@ func TestEnvironmentEVMRegistry_GetABIByType(t *testing.T) {
6874 }
6975
7076 abiObj , abiStr , err := registry .GetABIByType (typeAndVersion )
71- assert .NoError (t , err )
77+ require .NoError (t , err )
7278 assert .NotNil (t , abiObj )
73- assert .Equal (t , `[{"type":"function","name":"test","inputs":[]}]` , abiStr )
79+ assert .JSONEq (t , `[{"type":"function","name":"test","inputs":[]}]` , abiStr )
7480}
7581
7682func TestEnvironmentEVMRegistry_GetABIByType_NotFound (t * testing.T ) {
83+ t .Parallel ()
7784 registry := & environmentEVMRegistry {
7885 abiRegistry : map [string ]string {},
7986 }
@@ -84,11 +91,12 @@ func TestEnvironmentEVMRegistry_GetABIByType_NotFound(t *testing.T) {
8491 }
8592
8693 _ , _ , err := registry .GetABIByType (typeAndVersion )
87- assert .Error (t , err )
94+ require .Error (t , err )
8895 assert .Contains (t , err .Error (), "ABI not found" )
8996}
9097
9198func TestEnvironmentEVMRegistry_GetABIByType_InvalidABI (t * testing.T ) {
99+ t .Parallel ()
92100 typeAndVersion := deployment.TypeAndVersion {
93101 Type : deployment .ContractType ("test" ),
94102 Version : * semver .MustParse ("1.0.0" ),
@@ -101,11 +109,12 @@ func TestEnvironmentEVMRegistry_GetABIByType_InvalidABI(t *testing.T) {
101109 }
102110
103111 _ , _ , err := registry .GetABIByType (typeAndVersion )
104- assert .Error (t , err )
112+ require .Error (t , err )
105113 assert .Contains (t , err .Error (), "failed to parse ABI" )
106114}
107115
108116func TestEnvironmentEVMRegistry_GetAllABIs (t * testing.T ) {
117+ t .Parallel ()
109118 registry := & environmentEVMRegistry {
110119 abiRegistry : map [string ]string {
111120 "test:1.0.0" : `[{"type":"function","name":"test","inputs":[]}]` ,
@@ -117,11 +126,12 @@ func TestEnvironmentEVMRegistry_GetAllABIs(t *testing.T) {
117126 assert .Len (t , abis , 2 )
118127 assert .Contains (t , abis , "test:1.0.0" )
119128 assert .Contains (t , abis , "mock:2.0.0" )
120- assert .Equal (t , `[{"type":"function","name":"test","inputs":[]}]` , abis ["test:1.0.0" ])
121- assert .Equal (t , `[{"type":"function","name":"mock","inputs":[]}]` , abis ["mock:2.0.0" ])
129+ assert .JSONEq (t , `[{"type":"function","name":"test","inputs":[]}]` , abis ["test:1.0.0" ])
130+ assert .JSONEq (t , `[{"type":"function","name":"mock","inputs":[]}]` , abis ["mock:2.0.0" ])
122131}
123132
124133func TestEnvironmentEVMRegistry_AddABI (t * testing.T ) {
134+ t .Parallel ()
125135 registry := & environmentEVMRegistry {
126136 abiRegistry : map [string ]string {},
127137 }
@@ -133,13 +143,14 @@ func TestEnvironmentEVMRegistry_AddABI(t *testing.T) {
133143 abiStr := `[{"type":"function","name":"test","inputs":[]}]`
134144
135145 err := registry .AddABI (typeAndVersion , abiStr )
136- assert .NoError (t , err )
146+ require .NoError (t , err )
137147
138148 // Note: The current implementation doesn't modify the registry in place due to receiver type
139149 // This test verifies the method doesn't error on valid ABI
140150}
141151
142152func TestEnvironmentEVMRegistry_AddABI_InvalidABI (t * testing.T ) {
153+ t .Parallel ()
143154 registry := & environmentEVMRegistry {
144155 abiRegistry : map [string ]string {},
145156 }
@@ -151,6 +162,6 @@ func TestEnvironmentEVMRegistry_AddABI_InvalidABI(t *testing.T) {
151162 invalidABI := `invalid json`
152163
153164 err := registry .AddABI (typeAndVersion , invalidABI )
154- assert .Error (t , err )
165+ require .Error (t , err )
155166 assert .Contains (t , err .Error (), "failed to parse ABI" )
156167}
0 commit comments