mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-21 14:14:30 +00:00
## Why this should be merged Adds logging of `libevm` modification of default behaviour. ## How this works 1. Introduces `log.Lazy` functions to allow expensive logging operations to be computed i.f.f. required by the logging level. 2. Adds `Info` logging for registration of types and `Debug` logging for all else. 3. Only paths that change behaviour in a potentially unpredictable manner are logged; of note, RLP / JSON encoding is _not_ considered unpredictable given that registered extras are logged. 4. The minimal viable package, `set`, was necessary because we don't want to depend on `avalanchego` and the `hashicorp/go-set` latest version requires a later version of Go. #153 tracks a swap to the latter when possible. The `eth/tracers/internal/tracetest` test flaked at least twice (unrelated to these changes) so I've marked it as such since it's not worth a separate PR. ## How this was tested New unit test on `log.Lazy` + `set` methods. Existing CI for the rest as it's a refactor.
56 lines
1.5 KiB
Go
56 lines
1.5 KiB
Go
// Copyright 2025 the libevm authors.
|
|
//
|
|
// The libevm additions to go-ethereum are free software: you can redistribute
|
|
// them and/or modify them under the terms of the GNU Lesser General Public License
|
|
// as published by the Free Software Foundation, either version 3 of the License,
|
|
// or (at your option) any later version.
|
|
//
|
|
// The libevm additions are distributed in the hope that they will be useful,
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
|
|
// General Public License for more details.
|
|
//
|
|
// You should have received a copy of the GNU Lesser General Public License
|
|
// along with the go-ethereum library. If not, see
|
|
// <http://www.gnu.org/licenses/>.
|
|
|
|
package set
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestSub(t *testing.T) {
|
|
for _, tt := range [][3][]int{ // start, sub, want
|
|
{{}, {}, {}},
|
|
{{0}, {}, {0}},
|
|
{{}, {0}, {}},
|
|
{{0, 1}, {0}, {1}},
|
|
{{0, 1}, {1}, {0}},
|
|
} {
|
|
in, sub := tt[0], tt[1]
|
|
want := tt[2]
|
|
got := From(in...).Sub(From(sub...)).Slice()
|
|
assert.Equalf(t, want, got, "Set(%v).Sub(%v)", in, sub)
|
|
}
|
|
}
|
|
|
|
func TestIntersect(t *testing.T) {
|
|
for _, tt := range [][3][]int{ // L, R, intersection
|
|
{{}, {}, {}},
|
|
{{0}, {}, {}},
|
|
{{0}, {0}, {0}},
|
|
{{0, 1}, {0}, {0}},
|
|
{{0, 1}, {1}, {1}},
|
|
} {
|
|
want := tt[2]
|
|
|
|
for i := 0; i <= 1; i++ { // commutativity
|
|
lhs, rhs := tt[i], tt[1-i]
|
|
got := From(lhs...).Intersect(From(rhs...)).Slice()
|
|
assert.Equalf(t, want, got, "Set(%v).Intersect(%v)", lhs, rhs)
|
|
}
|
|
}
|
|
}
|