Files
bridge/opnet-watcher/plugins/plugin_test.go
T
zeekay 8c102b9cf9 test: 65 regression tests covering all security findings
Plugin tests (plugins/*_test.go):
- Chain ID constants: all 18 IDs verified, regression for old OPNET ID
- Solana parseLockEventFromLogs: 9 tests including amount offset regression
  (d[120:128] not d[112:120]), recipient extraction, discriminator, edge cases
- TON decodeVarUInteger16: 10 tests for 1/2/4/8 byte amounts, edge cases
- TON BOC parsing: findCellData with valid/short/nil/non-standard input
- EVM hexToBytes: 12 tests including 0x prefix, odd length, invalid chars
- Plugin constructors: name/chainID for all 4 plugin types

Config tests (config_test.go):
- DefaultConfig values: MaxBackingChangePct=15, ConfirmationDepth=6, CheckpointPath
- Validate: 10 tests for all required fields, threshold mode, single-key mode

Watcher tests (watcher_test.go): checkpoint save/load, dedup, atomic write
Relay tests (relay_test.go): nonceDirty flag, RLP encoding, funcSelector
2026-04-06 23:37:20 -07:00

33 lines
929 B
Go

// Copyright (C) 2025, Lux Industries Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package plugins
import "testing"
func TestChainIDConstants(t *testing.T) {
tests := []struct {
name string
got uint64
want uint64
}{
{"OPNETChainID", OPNETChainID, 4294967299}, // 0x100000003 -- NOT the old 1330663759
{"SolanaChainID", SolanaChainID, 1399811149}, // "SOLN"
{"TONChainID", TONChainID, 1414483791}, // "TONO"
}
for _, tt := range tests {
if tt.got != tt.want {
t.Errorf("%s = %d, want %d", tt.name, tt.got, tt.want)
}
}
}
// Regression: OPNETChainID was previously 1330663759 (0x4F504E4F).
// Must be 4294967299 (0x100000003) to match the Teleporter namespace.
func TestOPNETChainIDNotOldValue(t *testing.T) {
const oldBroken uint64 = 1330663759
if OPNETChainID == oldBroken {
t.Fatalf("OPNETChainID is the OLD broken value %d; must be 4294967299", oldBroken)
}
}