add cases.go as example of source of test cases
Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
parent
8aae4610e7
commit
36af7c8294
|
@ -0,0 +1,39 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/status-im/status-go/eth-node/crypto"
|
||||
"github.com/status-im/status-go/protocol/identity/alias"
|
||||
)
|
||||
|
||||
type Pair struct {
|
||||
publicKey string
|
||||
chatName string
|
||||
}
|
||||
|
||||
func genPubKeyAndName() (*Pair, error) {
|
||||
privateKey, err := crypto.GenerateKey()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
publicKey := hex.EncodeToString(crypto.FromECDSAPub(&privateKey.PublicKey))
|
||||
chatName := alias.GenerateFromPublicKey(&privateKey.PublicKey)
|
||||
return &Pair{publicKey, chatName}, nil
|
||||
}
|
||||
|
||||
/* Just run this file using `go run cases.go` */
|
||||
func main() {
|
||||
for i := 0; i < 9; i++ {
|
||||
pair, err := genPubKeyAndName()
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
os.Exit(1)
|
||||
}
|
||||
fmt.Printf(
|
||||
"{\"name\":\"%s\", \"key\":\"%s\"}\n",
|
||||
pair.chatName, pair.publicKey)
|
||||
}
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
import { test } from 'zora'
|
||||
import { chatKeyToChatName } from '../src/main.js'
|
||||
|
||||
/* Test cases generated using cases.go */
|
||||
const testCases = [
|
||||
{ name: "Enormous Vain Angwantibo",
|
||||
key: "0x041c678bdeb6940df3e436cee76612ae6177f46e54e541fc024b572fafd9be89ba43612d6e26bba8f3961b5d379efe1fb031a718ea24936a83550086f4ba2c5c94" },
|
||||
|
|
Loading…
Reference in New Issue