You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

51 lines
1.3 KiB

package loopdb
import (
"testing"
"github.com/lightninglabs/loop/looprpc"
"github.com/stretchr/testify/require"
)
// TestProtocolVersionSanity tests that protocol versions are sane, meaning
// we always keep our stored protocol version in sync with the RPC protocol
// version except for the unrecorded version.
func TestProtocolVersionSanity(t *testing.T) {
t.Parallel()
versions := [...]ProtocolVersion{
ProtocolVersionLegacy,
ProtocolVersionMultiLoopOut,
ProtocolVersionSegwitLoopIn,
ProtocolVersionPreimagePush,
ProtocolVersionUserExpiryLoopOut,
ProtocolVersionHtlcV2,
ProtocolVersionMultiLoopIn,
}
rpcVersions := [...]looprpc.ProtocolVersion{
looprpc.ProtocolVersion_LEGACY,
looprpc.ProtocolVersion_MULTI_LOOP_OUT,
looprpc.ProtocolVersion_NATIVE_SEGWIT_LOOP_IN,
looprpc.ProtocolVersion_PREIMAGE_PUSH_LOOP_OUT,
looprpc.ProtocolVersion_USER_EXPIRY_LOOP_OUT,
looprpc.ProtocolVersion_HTLC_V2,
looprpc.ProtocolVersion_MULTI_LOOP_IN,
}
require.Equal(t, len(versions), len(rpcVersions))
for i, version := range versions {
require.Equal(t, uint32(version), uint32(rpcVersions[i]))
}
// Finally test that the current version contants are up to date
require.Equal(t,
CurrentInternalProtocolVersion,
versions[len(versions)-1],
)
require.Equal(t,
uint32(CurrentInternalProtocolVersion),
uint32(CurrentRPCProtocolVersion),
)
}