add cases.go as example of source of test cases

Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
Jakub Sokołowski 2020-02-06 12:27:11 +01:00
parent 8aae4610e7
commit 36af7c8294
No known key found for this signature in database
GPG Key ID: 4EF064D0E6D63020
2 changed files with 40 additions and 0 deletions

39
test/cases.go Normal file
View File

@ -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)
}
}

View File

@ -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" },