|
17 | 17 | package params
|
18 | 18 |
|
19 | 19 | import (
|
| 20 | + "fmt" |
20 | 21 | "testing"
|
21 | 22 |
|
| 23 | + "github.com/stretchr/testify/assert" |
22 | 24 | "golang.org/x/mod/semver"
|
23 | 25 | )
|
24 | 26 |
|
25 |
| -func TestLibEVMVersioning(t *testing.T) { |
26 |
| - // We have an unusual version structure as defined by [LibEVMVersion] that |
27 |
| - // is easy to mess up, so it's easier to just automate it and test the |
28 |
| - // ordering assumptions. |
| 27 | +// libEVMServer automates the version rules described by the [LibEVMVersion] |
| 28 | +// documentation. |
| 29 | +type libEVMSemver struct { |
| 30 | + geth, libEVM semverTriplet |
| 31 | + typ ReleaseType |
| 32 | + rc uint |
| 33 | +} |
29 | 34 |
|
30 |
| - // This is a deliberate change-detector test to provide us with a copyable |
31 |
| - // string of the current version, useful for git tagging. |
32 |
| - const curr = "1.13.14-0.1.0.beta" |
33 |
| - if got, want := LibEVMVersion, curr; got != want { |
34 |
| - t.Errorf("got LibEVMVersion %q; want %q", got, want) |
| 35 | +func (v libEVMSemver) String() string { |
| 36 | + suffix := v.typ |
| 37 | + if suffix == ReleaseCandidate { |
| 38 | + suffix = ReleaseType(fmt.Sprintf("%s.%d", suffix, v.rc)) |
35 | 39 | }
|
| 40 | + return fmt.Sprintf("%s-%s.%s", v.geth, v.libEVM, suffix) |
| 41 | +} |
| 42 | + |
| 43 | +type semverTriplet struct { |
| 44 | + major, minor, patch uint |
| 45 | +} |
| 46 | + |
| 47 | +func (t semverTriplet) String() string { |
| 48 | + return fmt.Sprintf("%d.%d.%d", t.major, t.minor, t.patch) |
| 49 | +} |
| 50 | + |
| 51 | +func TestLibEVMVersioning(t *testing.T) { |
| 52 | + t.Run("current", func(t *testing.T) { |
| 53 | + want := libEVMSemver{ |
| 54 | + geth: semverTriplet{VersionMajor, VersionMinor, VersionPatch}, |
| 55 | + libEVM: semverTriplet{LibEVMVersionMajor, LibEVMVersionMinor, LibEVMVersionPatch}, |
| 56 | + typ: LibEVMReleaseType, |
| 57 | + rc: libEVMReleaseCandidate, |
| 58 | + }.String() |
| 59 | + assert.Equal(t, want, LibEVMVersion, "LibEVMVersion") |
| 60 | + }) |
36 | 61 |
|
37 | 62 | ordered := []libEVMSemver{
|
38 | 63 | {
|
|
0 commit comments