Loading tests/runtime_test.go +10 −5 Original line number Diff line number Diff line Loading @@ -236,7 +236,7 @@ nakama.register_rpc(test.printWorld, "helloworld") payload := "\"Hello World\"" client := &http.Client{} request, _ := http.NewRequest("POST", "http://localhost:7349/v2/rpc/helloworld?http_key=defaultkey", strings.NewReader(payload)) request, _ := http.NewRequest("POST", "http://localhost:7350/v2/rpc/helloworld?http_key=defaultkey", strings.NewReader(payload)) request.Header.Add("Content-Type", "Application/JSON") res, err := client.Do(request) if err != nil { Loading Loading @@ -483,6 +483,11 @@ nk.notification_send(user_id, subject, content, code, "", false) func TestRuntimeWalletWrite(t *testing.T) { modules := new(sync.Map) db := NewDB(t) uid := uuid.FromStringOrNil("95f05d94-cc66-445a-b4d1-9e262662cf79") InsertUser(t, db, uid) writeLuaModule(modules, "test", ` local nk = require("nakama") Loading @@ -491,7 +496,7 @@ local content = { } local user_id = "95f05d94-cc66-445a-b4d1-9e262662cf79" -- who to send nk.wallet_write(user_id, content) nk.wallet_update(user_id, content) `) rp := vm(t, modules) Loading Loading @@ -614,7 +619,7 @@ func TestRuntimeReqAfterHook(t *testing.T) { writeLuaModule(modules, "test", ` local nakama = require("nakama") function after_storage_write(ctx, payload) nakama.wallet_write(ctx.user_id, {gem = 10}) nakama.wallet_update(ctx.user_id, {gem = 10}) return payload end nakama.register_req_after(after_storage_write, "WriteStorageObjects") Loading Loading @@ -661,7 +666,7 @@ func TestRuntimeRTBeforeHook(t *testing.T) { writeLuaModule(modules, "test", ` local nakama = require("nakama") function before_match_create(ctx, payload) nakama.wallet_write(ctx.user_id, {gem = 20}) nakama.wallet_update(ctx.user_id, {gem = 20}) return payload end nakama.register_rt_before(before_match_create, "MatchCreate") Loading Loading @@ -712,7 +717,7 @@ end nakama.register_rt_before(before_match_create, "MatchCreate") function after_match_create(ctx, payload) nakama.wallet_write(ctx.user_id, {gem = 30}) nakama.wallet_update(ctx.user_id, {gem = 30}) return payload end nakama.register_rt_after(after_match_create, "MatchCreate") Loading tests/util.go +3 −3 Original line number Diff line number Diff line Loading @@ -37,8 +37,8 @@ import ( ) var ( config = server.NewConfig() logger = server.NewConsoleLogger(os.Stdout, true) config = server.NewConfig(logger) jsonpbMarshaler = &jsonpb.Marshaler{ EnumsAsInts: true, EmitDefaults: false, Loading Loading @@ -133,7 +133,7 @@ func NewSession(t *testing.T, customID string) (*grpc.ClientConn, api.NakamaClie outgoingCtx := metadata.NewOutgoingContext(ctx, metadata.New(map[string]string{ "authorization": "Basic " + base64.StdEncoding.EncodeToString([]byte("defaultkey:")), })) conn, err := grpc.DialContext(outgoingCtx, "localhost:7350", grpc.WithInsecure()) conn, err := grpc.DialContext(outgoingCtx, "localhost:7349", grpc.WithInsecure()) if err != nil { t.Fatal(err) } Loading @@ -160,7 +160,7 @@ func NewAuthenticatedAPIClient(t *testing.T, customID string) (*grpc.ClientConn, outgoingCtx := metadata.NewOutgoingContext(ctx, metadata.New(map[string]string{ "authorization": "Bearer " + session.Token, })) conn, err := grpc.DialContext(outgoingCtx, "localhost:7350", grpc.WithInsecure()) conn, err := grpc.DialContext(outgoingCtx, "localhost:7349", grpc.WithInsecure()) if err != nil { t.Fatal(err) } Loading Loading
tests/runtime_test.go +10 −5 Original line number Diff line number Diff line Loading @@ -236,7 +236,7 @@ nakama.register_rpc(test.printWorld, "helloworld") payload := "\"Hello World\"" client := &http.Client{} request, _ := http.NewRequest("POST", "http://localhost:7349/v2/rpc/helloworld?http_key=defaultkey", strings.NewReader(payload)) request, _ := http.NewRequest("POST", "http://localhost:7350/v2/rpc/helloworld?http_key=defaultkey", strings.NewReader(payload)) request.Header.Add("Content-Type", "Application/JSON") res, err := client.Do(request) if err != nil { Loading Loading @@ -483,6 +483,11 @@ nk.notification_send(user_id, subject, content, code, "", false) func TestRuntimeWalletWrite(t *testing.T) { modules := new(sync.Map) db := NewDB(t) uid := uuid.FromStringOrNil("95f05d94-cc66-445a-b4d1-9e262662cf79") InsertUser(t, db, uid) writeLuaModule(modules, "test", ` local nk = require("nakama") Loading @@ -491,7 +496,7 @@ local content = { } local user_id = "95f05d94-cc66-445a-b4d1-9e262662cf79" -- who to send nk.wallet_write(user_id, content) nk.wallet_update(user_id, content) `) rp := vm(t, modules) Loading Loading @@ -614,7 +619,7 @@ func TestRuntimeReqAfterHook(t *testing.T) { writeLuaModule(modules, "test", ` local nakama = require("nakama") function after_storage_write(ctx, payload) nakama.wallet_write(ctx.user_id, {gem = 10}) nakama.wallet_update(ctx.user_id, {gem = 10}) return payload end nakama.register_req_after(after_storage_write, "WriteStorageObjects") Loading Loading @@ -661,7 +666,7 @@ func TestRuntimeRTBeforeHook(t *testing.T) { writeLuaModule(modules, "test", ` local nakama = require("nakama") function before_match_create(ctx, payload) nakama.wallet_write(ctx.user_id, {gem = 20}) nakama.wallet_update(ctx.user_id, {gem = 20}) return payload end nakama.register_rt_before(before_match_create, "MatchCreate") Loading Loading @@ -712,7 +717,7 @@ end nakama.register_rt_before(before_match_create, "MatchCreate") function after_match_create(ctx, payload) nakama.wallet_write(ctx.user_id, {gem = 30}) nakama.wallet_update(ctx.user_id, {gem = 30}) return payload end nakama.register_rt_after(after_match_create, "MatchCreate") Loading
tests/util.go +3 −3 Original line number Diff line number Diff line Loading @@ -37,8 +37,8 @@ import ( ) var ( config = server.NewConfig() logger = server.NewConsoleLogger(os.Stdout, true) config = server.NewConfig(logger) jsonpbMarshaler = &jsonpb.Marshaler{ EnumsAsInts: true, EmitDefaults: false, Loading Loading @@ -133,7 +133,7 @@ func NewSession(t *testing.T, customID string) (*grpc.ClientConn, api.NakamaClie outgoingCtx := metadata.NewOutgoingContext(ctx, metadata.New(map[string]string{ "authorization": "Basic " + base64.StdEncoding.EncodeToString([]byte("defaultkey:")), })) conn, err := grpc.DialContext(outgoingCtx, "localhost:7350", grpc.WithInsecure()) conn, err := grpc.DialContext(outgoingCtx, "localhost:7349", grpc.WithInsecure()) if err != nil { t.Fatal(err) } Loading @@ -160,7 +160,7 @@ func NewAuthenticatedAPIClient(t *testing.T, customID string) (*grpc.ClientConn, outgoingCtx := metadata.NewOutgoingContext(ctx, metadata.New(map[string]string{ "authorization": "Bearer " + session.Token, })) conn, err := grpc.DialContext(outgoingCtx, "localhost:7350", grpc.WithInsecure()) conn, err := grpc.DialContext(outgoingCtx, "localhost:7349", grpc.WithInsecure()) if err != nil { t.Fatal(err) } Loading