Skip to content

Commit

Permalink
feat: add a couple of new LLMQ types (#17)
Browse files Browse the repository at this point in the history
* feat: add two more LLMQ types, LLMQType_TEST_PLATFORM (106) and LLMQType_DEVNET_PLATFORM (107)
  • Loading branch information
shotonoff committed Feb 21, 2023
1 parent 221b7c3 commit 0daa11d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
8 changes: 6 additions & 2 deletions btcjson/dashevocmds.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ const (
LLMQType_TEST_DIP0024 LLMQType = 103 // 4 members, 2 (66%) threshold, one per hour
LLMQType_TEST_INSTANTSEND LLMQType = 104 // 3 members, 2 (66%) threshold, one per hour
LLMQType_DEVNET_DIP0024 LLMQType = 105 // 8 members, 4 (50%) threshold, one per hour
LLMQType_TEST_PLATFORM LLMQType = 106 // 3 members, 2 (66%) threshold, one per hour
LLMQType_DEVNET_PLATFORM LLMQType = 107 // 12 members, 8 (67%) threshold, one per hour

// LLMQType_5_60 is replaced with LLMQType_TEST to adhere to DIP-0006 naming
LLMQType_5_60 LLMQType = LLMQType_TEST
Expand All @@ -145,7 +147,7 @@ var (
errWrongSizeOfArgs = errors.New("wrong size of arguments")
errQuorumUnmarshalerNotFound = errors.New("quorum unmarshaler not found")

llmqTypes map[string]LLMQType = map[string]LLMQType{
llmqTypes = map[string]LLMQType{
"llmq_50_60": LLMQType_50_60,
"llmq_400_60": LLMQType_400_60,
"llmq_400_85": LLMQType_400_85,
Expand All @@ -157,6 +159,8 @@ var (
"llmq_test_dip0024": LLMQType_TEST_DIP0024,
"llmq_test_instantsend": LLMQType_TEST_INSTANTSEND,
"llmq_devnet_dip0024": LLMQType_DEVNET_DIP0024,
"llmq_test_platform": LLMQType_TEST_PLATFORM,
"llmq_devnet_platform": LLMQType_DEVNET_PLATFORM,
}
)

Expand All @@ -182,7 +186,7 @@ func (t LLMQType) Name() string {
// defined in accordance with DIP-0006.
// See https://github.com/dashpay/dips/blob/master/dip-0006/llmq-types.md
func (t LLMQType) Validate() error {
if (t >= LLMQType_50_60 && t <= LLMQType_60_75) || (t >= LLMQType_TEST && t <= LLMQType_DEVNET_DIP0024) {
if (t >= LLMQType_50_60 && t <= LLMQType_60_75) || (t >= LLMQType_TEST && t <= LLMQType_DEVNET_PLATFORM) {
return nil
}

Expand Down
15 changes: 14 additions & 1 deletion btcjson/dashevocmds_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,20 @@ func TestLLMQTypeValidate(t *testing.T) {
testCases := []struct {
llmqType btcjson.LLMQType
expectErr bool
}{{-1, true}, {0, true}, {1, false}, {2, false}, {5, false}, {6, true}, {99, true}, {100, false}, {105, false}, {106, true}}
}{
{-1, true},
{0, true},
{1, false},
{2, false},
{5, false},
{6, true},
{99, true},
{100, false},
{105, false},
{106, false},
{107, false},
{108, true},
}

for _, tc := range testCases {
t.Run(strconv.Itoa(int(tc.llmqType)), func(t *testing.T) {
Expand Down

0 comments on commit 0daa11d

Please sign in to comment.