diff --git a/cmd/celestia/rpc.go b/cmd/celestia/rpc.go index d413da1d51..8f260d43bb 100644 --- a/cmd/celestia/rpc.go +++ b/cmd/celestia/rpc.go @@ -113,17 +113,17 @@ func parseParams(method string, params []string) []interface{} { } parsedParams[0] = root // 2. NamespaceID - nID, err := parseNamespace(params[1]) + nID, err := parseNamespaceID(params[1]) if err != nil { - panic(fmt.Sprintf("Error parsing namespace: %v", err)) + panic(fmt.Sprintf("Error parsing namespace ID: %v", err)) } parsedParams[1] = nID case "Submit": // 1. NamespaceID var err error - nID, err := parseNamespace(params[0]) + nID, err := parseNamespaceID(params[0]) if err != nil { - panic(fmt.Sprintf("Error parsing namespace: %v", err)) + panic(fmt.Sprintf("Error parsing namespace ID: %v", err)) } // 2. Blob data var blobData []byte @@ -163,9 +163,9 @@ func parseParams(method string, params []string) []interface{} { } parsedParams[1] = num // 3. NamespaceID - nID, err := parseNamespace(params[2]) + nID, err := parseNamespaceID(params[2]) if err != nil { - panic(fmt.Sprintf("Error parsing namespace: %v", err)) + panic(fmt.Sprintf("Error parsing namespace ID: %v", err)) } // 4. Blob data var blobData []byte @@ -202,9 +202,9 @@ func parseParams(method string, params []string) []interface{} { } parsedParams[0] = num // 2. NamespaceID - nID, err := parseNamespace(params[1]) + nID, err := parseNamespaceID(params[1]) if err != nil { - panic(fmt.Sprintf("Error parsing namespace: %v", err)) + panic(fmt.Sprintf("Error parsing namespace ID: %v", err)) } parsedParams[1] = nID // 3: Commitment @@ -222,9 +222,9 @@ func parseParams(method string, params []string) []interface{} { } parsedParams[0] = num // 2. NamespaceID - nID, err := parseNamespace(params[1]) + nID, err := parseNamespaceID(params[1]) if err != nil { - panic(fmt.Sprintf("Error parsing namespace: %v", err)) + panic(fmt.Sprintf("Error parsing namespace ID: %v", err)) } parsedParams[1] = []namespace.ID{nID} return parsedParams @@ -419,7 +419,7 @@ func parseSignatureForHelpstring(methodSig reflect.StructField) string { return simplifiedSignature } -func parseNamespace(param string) (namespace.ID, error) { +func parseNamespaceID(param string) (namespace.ID, error) { var nID []byte var err error if strings.HasPrefix(param, "0x") { diff --git a/cmd/celestia/rpc_test.go b/cmd/celestia/rpc_test.go index 6d3011c198..f16042c80d 100644 --- a/cmd/celestia/rpc_test.go +++ b/cmd/celestia/rpc_test.go @@ -8,7 +8,7 @@ import ( "github.com/celestiaorg/nmt/namespace" ) -func Test_parseNamespace(t *testing.T) { +func Test_parseNamespaceID(t *testing.T) { type testCase struct { name string param string @@ -17,7 +17,7 @@ func Test_parseNamespace(t *testing.T) { } testCases := []testCase{ { - name: "8 byte hex encoded namespace gets right padded", + name: "8 byte hex encoded namespace ID gets right padded", param: "0x0c204d39600fddd3", want: namespace.ID{ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, @@ -26,7 +26,7 @@ func Test_parseNamespace(t *testing.T) { wantErr: false, }, { - name: "10 byte hex encoded namespace", + name: "10 byte hex encoded namespace ID", param: "0x42690c204d39600fddd3", want: namespace.ID{ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, @@ -35,7 +35,7 @@ func Test_parseNamespace(t *testing.T) { wantErr: false, }, { - name: "29 byte hex encoded namespace", + name: "29 byte hex encoded namespace ID", param: "0x0000000000000000000000000000000000000001010101010101010101", want: namespace.ID{ 0x0, // namespace version @@ -45,13 +45,13 @@ func Test_parseNamespace(t *testing.T) { wantErr: false, }, { - name: "11 byte hex encoded namespace returns error", + name: "11 byte hex encoded namespace ID returns error", param: "0x42690c204d39600fddd3a3", want: namespace.ID{}, wantErr: true, }, { - name: "10 byte base64 encoded namespace", + name: "10 byte base64 encoded namespace ID", param: "QmkMIE05YA/d0w==", want: namespace.ID{ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, @@ -60,7 +60,7 @@ func Test_parseNamespace(t *testing.T) { wantErr: false, }, { - name: "not base64 or hex encoded namespace returns error", + name: "not base64 or hex encoded namespace ID returns error", param: "5748493939429", want: namespace.ID{}, wantErr: true, @@ -69,7 +69,7 @@ func Test_parseNamespace(t *testing.T) { for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { - got, err := parseNamespace(tc.param) + got, err := parseNamespaceID(tc.param) if tc.wantErr { assert.Error(t, err) return