Commit 534501b3 authored by vipwzw's avatar vipwzw Committed by 33cn

update 01/23

parent 968ea20c
......@@ -214,7 +214,7 @@ function auto_test() {
fi
echo "=========== #config token blacklist ============="
rawData=$(${CLI} config config_tx -k token-blacklist -o add -v BTC)
rawData=$(${CLI} config config_tx -c token-blacklist -o add -v BTC)
signData=$(${CLI} wallet sign -d "${rawData}" -k 0xc34b5d9d44ac7b754806f761d3d4d2c4fe5214f6b074c19f069c4f5c2a29c8cc)
hash=$(${CLI} wallet send -d "${signData}")
block_wait "${CLI}" 2
......
......@@ -130,7 +130,7 @@ function start_chain33() {
fi
echo "=========== #config token blacklist ============="
rawData=$(${CLI} config config_tx -k token-blacklist -o add -v BTC)
rawData=$(${CLI} config config_tx -c token-blacklist -o add -v BTC)
signData=$(${CLI} wallet sign -d "${rawData}" -k 0xc34b5d9d44ac7b754806f761d3d4d2c4fe5214f6b074c19f069c4f5c2a29c8cc)
hash=$(${CLI} wallet send -d "${signData}")
......
......@@ -143,7 +143,7 @@ function start_chain33() {
fi
echo "=========== #config token blacklist ============="
rawData=$(${CLI} config config_tx -k token-blacklist -o add -v BTC)
rawData=$(${CLI} config config_tx -c token-blacklist -o add -v BTC)
signData=$(${CLI} wallet sign -d "${rawData}" -k 0xc34b5d9d44ac7b754806f761d3d4d2c4fe5214f6b074c19f069c4f5c2a29c8cc)
hash=$(${CLI} wallet send -d "${signData}")
......
#!/usr/bin/env bash
guodun="$(../chain33-cli config config_tx -k token-blacklist -o add -v BTY --paraName "user.p.guodun.")"
fzmtest="$(../chain33-cli config config_tx -k token-blacklist -o add -v BTY --paraName "user.p.fzmtest.")"
guodun="$(../chain33-cli config config_tx -c token-blacklist -o add -v BTY --paraName "user.p.guodun.")"
fzmtest="$(../chain33-cli config config_tx -c token-blacklist -o add -v BTY --paraName "user.p.fzmtest.")"
echo "cli wallet sign -d $guodun -a 1JmFaA6unrCFYEWPGRi7uuXY1KthTJxJEP -e 1h > d:/b.txt"
echo "cli wallet sign -d $fzmtest -a 1JmFaA6unrCFYEWPGRi7uuXY1KthTJxJEP -e 1h >> d:/b.txt"
#!/usr/bin/env bash
fzmtest="$(../chain33-cli --paraName user.p.fzmtest. config config_tx -k lottery-creator -o add -v 15nn4D2ppUj8tmyHfdm8g4EvtqpBYUS7DM)"
fzmtest="$(../chain33-cli --paraName user.p.fzmtest. config config_tx -c lottery-creator -o add -v 15nn4D2ppUj8tmyHfdm8g4EvtqpBYUS7DM)"
echo "cli wallet sign -d $fzmtest -a 1JmFaA6unrCFYEWPGRi7uuXY1KthTJxJEP -e 1h >> d:/b.txt"
#!/usr/bin/env bash
guodun1=$(../chain33-cli config config_tx -k token-blacklist -o add -v BTY --paraName "user.p.$2.")
guodun2=$(../chain33-cli config config_tx -k token-finisher -o add -v "$1" --paraName "user.p.$2.")
guodun1=$(../chain33-cli config config_tx -c token-blacklist -o add -v BTY --paraName "user.p.$2.")
guodun2=$(../chain33-cli config config_tx -c token-finisher -o add -v "$1" --paraName "user.p.$2.")
echo "cli wallet sign -d $guodun1 -a 1JmFaA6unrCFYEWPGRi7uuXY1KthTJxJEP -e 1h > d:/b.txt"
echo "cli wallet sign -d $guodun2 -a 1JmFaA6unrCFYEWPGRi7uuXY1KthTJxJEP -e 1h >> d:/b.txt"
......@@ -88,9 +88,9 @@ func isAllowLocalKey2(execer []byte, key []byte) error {
err := errors.Wrapf(types.ErrLocalKeyLen, "isAllowLocalKey too short. key=%s exec=%s", string(key), string(execer))
return err
}
if key[minkeylen-1] != '-' {
if key[minkeylen-1] != '-' || key[len(types.LocalPrefix)] != '-' {
err := errors.Wrapf(types.ErrLocalPrefix,
"isAllowLocalKey prefix last char is not '-'. key=%s exec=%s minkeylen=%d title=%s",
"isAllowLocalKey prefix last char or separator is not '-'. key=%s exec=%s minkeylen=%d title=%s",
string(key), string(execer), minkeylen, types.GetTitle())
return err
}
......
......@@ -130,6 +130,8 @@ func TestKeyAllow_evm(t *testing.T) {
func TestKeyLocalAllow(t *testing.T) {
err := isAllowLocalKey([]byte("token"), []byte("LODB-token-"))
assert.Equal(t, err, types.ErrLocalKeyLen)
err = isAllowLocalKey([]byte("token"), []byte("LODB_token-a"))
assert.Equal(t, err, types.ErrLocalPrefix)
err = isAllowLocalKey([]byte("token"), []byte("LODB-token-a"))
assert.Nil(t, err)
err = isAllowLocalKey([]byte(""), []byte("LODB--a"))
......
......@@ -46,6 +46,37 @@ func TestMultipleGRPC(t *testing.T) {
assert.Equal(t, reply.Hash, []byte("hello"))
}
func TestMultipleGRPCLocalhost(t *testing.T) {
qapi := new(mocks.QueueProtocolAPI)
qapi.On("Query", "ticket", "RandNumHash", mock.Anything).Return(&types.ReplyHash{Hash: []byte("hello")}, nil)
//testnode setup
rpcCfg := new(types.RPC)
rpcCfg.GrpcBindAddr = "localhost:8003"
rpcCfg.JrpcBindAddr = "localhost:8004"
rpcCfg.MainnetJrpcAddr = rpcCfg.JrpcBindAddr
rpcCfg.Whitelist = []string{"localhost", "0.0.0.0"}
rpcCfg.JrpcFuncWhitelist = []string{"*"}
rpcCfg.GrpcFuncWhitelist = []string{"*"}
rpc.InitCfg(rpcCfg)
server := rpc.NewGRpcServer(&qmocks.Client{}, qapi)
assert.NotNil(t, server)
go server.Listen()
time.Sleep(time.Second)
//一个IP 有效,一个IP 无效
paraRemoteGrpcClient := "localhost:8004,localhost:8003,localhost"
conn, err := grpc.Dial(grpcclient.NewMultipleURL(paraRemoteGrpcClient), grpc.WithInsecure())
assert.Nil(t, err)
grpcClient := types.NewChain33Client(conn)
param := &types.ReqRandHash{
ExecName: "ticket",
BlockNum: 5,
Hash: []byte("hello"),
}
reply, err := grpcClient.QueryRandNum(context.Background(), param)
assert.Nil(t, err)
assert.Equal(t, reply.Hash, []byte("hello"))
}
func TestNewParaClient(t *testing.T) {
qapi := new(mocks.QueueProtocolAPI)
qapi.On("Query", "ticket", "RandNumHash", mock.Anything).Return(&types.ReplyHash{Hash: []byte("hello")}, nil)
......
......@@ -62,7 +62,7 @@ func (*multipleBuilder) Build(target resolver.Target, cc resolver.ClientConn, op
return nil, err
}
if net.ParseIP(host) != nil {
if host != "" {
r.addrs = append(r.addrs, resolver.Address{Addr: host + ":" + port})
}
}
......
......@@ -47,8 +47,8 @@ func ConfigTxCmd() *cobra.Command {
}
func addConfigTxFlags(cmd *cobra.Command) {
cmd.Flags().StringP("key", "k", "", "key string")
cmd.MarkFlagRequired("key")
cmd.Flags().StringP("config_key", "c", "", "config key string")
cmd.MarkFlagRequired("config_key")
cmd.Flags().StringP("operation", "o", "", "adding or deletion operation")
cmd.MarkFlagRequired("operation")
......@@ -60,7 +60,7 @@ func addConfigTxFlags(cmd *cobra.Command) {
func configTx(cmd *cobra.Command, args []string) {
paraName, _ := cmd.Flags().GetString("paraName")
key, _ := cmd.Flags().GetString("key")
key, _ := cmd.Flags().GetString("config_key")
op, _ := cmd.Flags().GetString("operation")
opAddr, _ := cmd.Flags().GetString("value")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment