server/control_data_test.go (21514B)
1 package main 2 3 import ( 4 "bytes" 5 "encoding/binary" 6 "net/http" 7 "net/http/httptest" 8 "net/url" 9 "regexp" 10 "strings" 11 "testing" 12 ) 13 14 func TestControlItemCatalogPaginatesAndFilters(t *testing.T) { 15 world := &server{ 16 worldServices: worldServices{baseURL: "/share/test/"}} 17 handler := adminTestHandler(world) 18 19 first, second, filtered := httptest.NewRecorder(), httptest.NewRecorder(), httptest.NewRecorder() 20 handler.ServeHTTP(first, httptest.NewRequest("GET", "/share/test/admin/items/catalog?catalog=armor", nil)) 21 handler.ServeHTTP(second, httptest.NewRequest("GET", "/share/test/admin/items/catalog?catalog=armor&page=2", nil)) 22 handler.ServeHTTP(filtered, httptest.NewRequest("GET", "/share/test/admin/items/catalog?catalog=121567", nil)) 23 24 if first.Code != http.StatusOK || strings.Count(first.Body.String(), "<button name='template' value='") != 1000 { 25 t.Fatal("first catalog page must contain 1000 templates") 26 } 27 if count := strings.Count(second.Body.String(), "<button name='template' value='"); second.Code != http.StatusOK || count == 0 || count > 1000 { 28 t.Fatal("second catalog page must contain up to 1000 remaining templates") 29 } 30 if !strings.Contains(first.Body.String(), "href='admin/items/catalog?catalog=armor&page=2'") || 31 !strings.Contains(second.Body.String(), "href='admin/items/catalog?catalog=armor&page=1'") || 32 !strings.Contains(first.Body.String(), "<base href='/share/test/'>") { 33 t.Fatal("pagination lost the filter or public mounting path") 34 } 35 ids := regexp.MustCompile(`<button name='template' value='([0-9]+)'>`).FindAllStringSubmatch(first.Body.String(), -1) 36 for _, id := range ids { 37 if strings.Contains(second.Body.String(), "<button name='template' value='"+id[1]+"'>") { 38 t.Fatal("pages overlap") 39 } 40 } 41 if filtered.Code != http.StatusOK || strings.Count(filtered.Body.String(), "<button name='template' value='") != 1 || 42 !strings.Contains(filtered.Body.String(), "Solar-Powered Pistol</a></td>") || !strings.Contains(filtered.Body.String(), "value='121567'>Create</button>") { 43 t.Fatal("catalog filter did not select the exact template") 44 } 45 } 46 47 func TestControlInstancesPaginateFilteredResults(t *testing.T) { 48 world := &server{ 49 worldServices: worldServices{baseURL: "/"}, items: make(map[uint32]itemRecord)} 50 for id := uint32(1); id <= 1001; id++ { 51 world.items[id] = itemRecord{Type: 51018, Template: 121567, Quality: 1, Count: 1} 52 } 53 t.Chdir(t.TempDir()) 54 openTestDatabase(t, world) 55 for id, item := range world.items { 56 if _, err := world.db.Exec("INSERT INTO items(id,type,template,quality,count,ammo) VALUES(?,?,?,?,?,?)", id, item.Type, item.Template, item.Quality, item.Count, item.Ammo); err != nil { 57 t.Fatal(err) 58 } 59 } 60 handler := adminTestHandler(world) 61 62 first, second, last, empty := httptest.NewRecorder(), httptest.NewRecorder(), httptest.NewRecorder(), httptest.NewRecorder() 63 handler.ServeHTTP(first, httptest.NewRequest("GET", "/admin/items?q=pistol", nil)) 64 handler.ServeHTTP(second, httptest.NewRequest("GET", "/admin/items?q=pistol&page=2", nil)) 65 handler.ServeHTTP(last, httptest.NewRequest("GET", "/admin/items?q=pistol&page=999999999", nil)) 66 handler.ServeHTTP(empty, httptest.NewRequest("GET", "/admin/items?q=missing&page=-1", nil)) 67 68 if strings.Count(first.Body.String(), "<tr>") != 1001 || strings.Count(second.Body.String(), "<tr>") != 2 || 69 strings.Count(last.Body.String(), "<tr>") != 2 || strings.Count(empty.Body.String(), "<tr>") != 2 { 70 t.Fatal("instance pages did not contain 1000, 1, 1 and an empty-result row") 71 } 72 if !strings.Contains(second.Body.String(), "href='admin/items/1001'") || strings.Contains(second.Body.String(), "href='admin/items/1000'") || 73 !strings.Contains(first.Body.String(), "href='admin/items?page=2&q=pistol'") || !strings.Contains(last.Body.String(), "Page 2 of 2") || !strings.Contains(empty.Body.String(), "Page 1 of 1") { 74 t.Fatal("instance boundaries or retained filter are incorrect") 75 } 76 } 77 78 func postControlForm(world *server, path string, fields url.Values) *httptest.ResponseRecorder { 79 request := httptest.NewRequest("POST", path, strings.NewReader(fields.Encode())) 80 request.Header.Set("Content-Type", "application/x-www-form-urlencoded") 81 response := httptest.NewRecorder() 82 serveAdminTestRequest(world, response, request) 83 return response 84 } 85 86 func TestControlItemsShareOneRegistryAndShowOwnersAndBackpackContents(t *testing.T) { 87 useNPCData(t, testNPCData()) 88 world := newTestServer(t) 89 postControlForm(world, "/admin/players", url.Values{"name": {"Explorer"}}) 90 91 pistol := postControlForm(world, "/admin/items", url.Values{"template": {"121567"}}) 92 bag := postControlForm(world, "/admin/items", url.Values{"template": {"99228"}}) 93 contained := postControlForm(world, "/admin/items", url.Values{"template": {"121567"}}) 94 placed := postControlForm(world, "/admin/players/1", playerFixtureForm("inventory:\n slots: {inventory_slot_1: 1, inventory_slot_2: 2}\n")) 95 filled := postControlForm(world, "/admin/items/2", url.Values{"type": {"51017"}, "template": {"99228"}, "quality": {"1"}, "count": {"1"}, "slots.slot_1": {"3"}}) 96 restarted := newServerForTest(t) 97 page := httptest.NewRecorder() 98 adminTestHandler(restarted).ServeHTTP(page, httptest.NewRequest("GET", "/admin/items?q=Explorer", nil)) 99 details := httptest.NewRecorder() 100 adminTestHandler(restarted).ServeHTTP(details, httptest.NewRequest("GET", "/admin/items/1", nil)) 101 102 for _, response := range []*httptest.ResponseRecorder{pistol, bag, contained, placed, filled} { 103 if response.Code != http.StatusSeeOther { 104 t.Fatalf("item operation: %d %s", response.Code, response.Body.String()) 105 } 106 } 107 if len(restarted.items) != 3 || restarted.nextItem != 3 || restarted.items[1].Template != 121567 || restarted.items[2].Template != 99228 { 108 t.Fatalf("global registry: %+v", restarted.items) 109 } 110 inventory := restarted.characters[1].inventory 111 if len(inventory.Items) != 2 || inventory.Items[0] != (ownedItem{ID: 1, Type: 51018, Template: 121567, Quality: 1, Slot: 64, Count: 1}) || inventory.Items[1] != (ownedItem{ID: 2, Type: 51017, Template: 99228, Quality: 1, Slot: 65, Count: 1}) || 112 len(inventory.Containers[2]) != 1 || inventory.Containers[2][0] != (ownedItem{ID: 3, Type: 51018, Template: 121567, Quality: 1, Slot: 0, Count: 1}) { 113 t.Fatalf("slot references lost their items: %+v", inventory) 114 } 115 if page.Code != http.StatusOK || !strings.Contains(page.Body.String(), "Solar-Powered Pistol") || !strings.Contains(page.Body.String(), "Explorer (1)") || 116 !strings.Contains(page.Body.String(), "Container 2, slot_1") || !strings.Contains(page.Body.String(), "href='admin/items/3'") { 117 t.Fatalf("item list: %d %s", page.Code, page.Body.String()) 118 } 119 if details.Code != http.StatusOK || !strings.Contains(details.Body.String(), "Instance properties") || !strings.Contains(details.Body.String(), "Catalog properties") { 120 t.Fatalf("item properties: %d %s", details.Code, details.Body.String()) 121 } 122 contents, err := readTestItemStore(world) 123 if err != nil || !strings.Contains(string(contents), `"inventory_slot_30":null`) || !strings.Contains(string(contents), `"slot_21":null`) || strings.Contains(string(contents), `"Slot":64`) { 124 t.Fatalf("item snapshot is not slot-based: %s, %v", contents, err) 125 } 126 } 127 128 func TestControlItemFormSavesAndReopensBackpackSlots(t *testing.T) { 129 world := newControlInventoryWorld(t) 130 handler := adminTestHandler(world) 131 page := adminRequest(handler, "GET", "/admin/items/3", "", nil) 132 if page.Code != http.StatusOK || strings.Contains(page.Body.String(), "<textarea") { 133 t.Fatal("expected an HTML item form", page.Code) 134 } 135 fields := playerPageValues(t, page.Body.String()) 136 if len(fields) != 26 || fields.Get("type") != "51017" || fields.Get("template") != "99228" || 137 fields.Get("quality") != "1" || fields.Get("count") != "1" || fields.Get("ammo") != "0" || 138 fields.Get("slots.slot_1") != "4" { 139 t.Fatal("unexpected item fields", fields) 140 } 141 142 fields.Set("slots.slot_1", "") 143 fields.Set("slots.slot_21", "4") 144 saved := postControlForm(world, "/admin/items/3", fields) 145 restarted := newServerForTest(t) 146 reopened := adminRequest(adminTestHandler(restarted), "GET", "/admin/items/3", "", nil) 147 values := playerPageValues(t, reopened.Body.String()) 148 if saved.Code != http.StatusSeeOther || reopened.Code != http.StatusOK || 149 values.Get("slots.slot_1") != "" || values.Get("slots.slot_21") != "4" { 150 t.Fatal("backpack slot edit did not survive restart", saved.Code, values) 151 } 152 } 153 154 func TestControlItemCanBeUnassignedAndTransferredWithoutChangingID(t *testing.T) { 155 useNPCData(t, testNPCData()) 156 world := newTestServer(t) 157 postControlForm(world, "/admin/players", url.Values{"name": {"First"}}) 158 postControlForm(world, "/admin/players", url.Values{"name": {"Second"}}) 159 postControlForm(world, "/admin/items", url.Values{"template": {"121567"}}) 160 postControlForm(world, "/admin/players/1", playerFixtureForm("inventory:\n slots: {inventory_slot_1: 1}\n")) 161 162 cleared := postControlForm(world, "/admin/players/1", playerFixtureForm("inventory:\n slots: {inventory_slot_1: null}\n")) 163 unassigned := newServerForTest(t) 164 transferred := postControlForm(world, "/admin/players/2", playerFixtureForm("inventory:\n slots: {inventory_slot_30: 1}\n")) 165 restarted := newServerForTest(t) 166 postControlForm(restarted, "/admin/items", url.Values{"template": {"121567"}}) 167 168 if cleared.Code != http.StatusSeeOther || transferred.Code != http.StatusSeeOther || len(unassigned.items) != 1 || len(unassigned.characters[1].inventory.Items) != 0 { 169 t.Fatalf("unassignment or transfer failed: %d %d", cleared.Code, transferred.Code) 170 } 171 if len(restarted.characters[1].inventory.Items) != 0 || len(restarted.characters[2].inventory.Items) != 1 || 172 restarted.characters[2].inventory.Items[0] != (ownedItem{ID: 1, Type: 51018, Template: 121567, Quality: 1, Slot: 93, Count: 1}) || restarted.nextItem != 2 { 173 t.Fatal("transfer lost identity or reused a global ID") 174 } 175 } 176 177 func TestControlInventoryRejectsDuplicateUnknownAndInvalidSlotsAtomically(t *testing.T) { 178 for _, contents := range []string{ 179 "slots: {inventory_slot_1: 1}\n", 180 "slots: {inventory_slot_1: 2, inventory_slot_2: 2}\n", 181 "slots: {inventory_slot_1: 99}\n", 182 "slots: {inventory_slot_31: 2}\n", 183 "slots: {inventory_slot_1: 2, inventory_slot_1: null}\n", 184 "slots: {inventory_slot_1: {id: 2}}\n", 185 } { 186 t.Run(contents, func(t *testing.T) { 187 useNPCData(t, testNPCData()) 188 world := newTestServer(t) 189 postControlForm(world, "/admin/players", url.Values{"name": {"First"}}) 190 postControlForm(world, "/admin/players", url.Values{"name": {"Second"}}) 191 postControlForm(world, "/admin/items", url.Values{"template": {"121567"}}) 192 postControlForm(world, "/admin/items", url.Values{"template": {"121567"}}) 193 postControlForm(world, "/admin/players/1", playerFixtureForm("inventory:\n slots: {inventory_slot_1: 1}\n")) 194 before, err := readTestItemStore(world) 195 if err != nil { 196 t.Fatal(err) 197 } 198 199 response := postControlForm(world, "/admin/players/2", playerFixtureForm("inventory:\n "+contents)) 200 after, readError := readTestItemStore(world) 201 202 if response.Code != http.StatusBadRequest || readError != nil || !bytes.Equal(before, after) || len(world.characters[2].inventory.Items) != 0 || world.nextItem != 2 { 203 t.Fatalf("invalid inventory edit changed state: %d %s", response.Code, response.Body.String()) 204 } 205 }) 206 } 207 } 208 209 func TestControlItemCreationKeepsStateWhenSavingFails(t *testing.T) { 210 useNPCData(t, testNPCData()) 211 world := newTestServer(t) 212 failDatabaseWrites(t, world) 213 214 response := postControlForm(world, "/admin/items", url.Values{"template": {"121567"}}) 215 216 if response.Code != http.StatusInternalServerError || world.nextItem != 0 || len(world.items) != 0 { 217 t.Fatalf("failed save changed registry: %d %s", response.Code, response.Body.String()) 218 } 219 } 220 221 func TestControlEditorShowsAllSkillCategoriesAndDefaultFields(t *testing.T) { 222 useNPCData(t, testNPCData()) 223 world := newTestServer(t) 224 postControlForm(world, "/admin/players", url.Values{"name": {"Explorer"}}) 225 contents := "id: 1\nname: Explorer\nappearance: {race: 1, fatness: 1, breed: 1, sex: 2, side: 1, head: 0}\nlevel: 1\nstats:\n body:\n martial_arts: 0\n" 226 if response := postControlForm(world, "/admin/players/1", playerFixtureForm(contents)); response.Code != http.StatusSeeOther { 227 t.Fatal(response.Body.String()) 228 } 229 230 page := httptest.NewRecorder() 231 adminTestHandler(world).ServeHTTP(page, httptest.NewRequest("GET", "/admin/players/1", nil)) 232 fields := playerPageValues(t, page.Body.String()) 233 234 if page.Code != http.StatusOK || strings.Contains(page.Body.String(), "<textarea") { 235 t.Fatalf("form: %d %s", page.Code, page.Body.String()) 236 } 237 for category, count := range map[string]int{"abilities": 6, "body": 8, "melee": 10, "misc_weapons": 3, "ranged": 13, "speed": 9, "trade_repair": 10, "nano_aiding": 8, "spying": 4, "navigation": 4} { 238 actual := 0 239 for name := range fields { 240 if strings.HasPrefix(name, "stats."+category+".") { 241 actual++ 242 } 243 } 244 if actual != count { 245 t.Fatalf("incomplete %s category: %d", category, actual) 246 } 247 } 248 for name, expected := range map[string]string{"stats.improvement_points": "1500", "stats.body.martial_arts": "0", "stats.abilities.strength": "6", "stats.ranged.rifle": "5", "stats.speed.run_speed": "5", "inventory.credits": "0", "inventory.slots.inventory_slot_1": "", "inventory.slots.inventory_slot_30": "", "return_door.playfield": "0", "return_door.door": "0"} { 249 if value, exists := fields[name]; !exists || len(value) != 1 || value[0] != expected { 250 t.Fatalf("field %s: %v", name, value) 251 } 252 } 253 254 } 255 256 func TestControlNestedSkillsAndImprovementPointsPersistAndReachClient(t *testing.T) { 257 useNPCData(t, testNPCData()) 258 world := newTestServer(t) 259 postControlForm(world, "/admin/players", url.Values{"name": {"Explorer"}}) 260 contents := "id: 1\nname: Explorer\nappearance: {race: 1, fatness: 1, breed: 1, sex: 2, side: 1, head: 0}\nlevel: 1\nstats:\n improvement_points: 12345\n ranged:\n rifle: 42\n spying:\n concealment: 87\n" 261 262 response := postControlForm(world, "/admin/players/1", playerFixtureForm(contents)) 263 restarted := newServerForTest(t) 264 packet := fullCharacterPacket(restarted.characters[1]) 265 values := make(map[uint32]uint32) 266 count := binary.BigEndian.Uint32(packet[64:68])/1009 - 1 267 for offset := 68; offset < 68+int(count)*8; offset += 8 { 268 values[binary.BigEndian.Uint32(packet[offset:])] = binary.BigEndian.Uint32(packet[offset+4:]) 269 } 270 271 if response.Code != http.StatusSeeOther || restarted.characters[1].stats.ImprovementPoints != 12345 || restarted.characters[1].stats.Ranged.Rifle != 42 || restarted.characters[1].stats.Spying.Concealment != 87 { 272 t.Fatalf("nested skills or IP lost: %d %s", response.Code, response.Body.String()) 273 } 274 if values[53] != 12345 || values[113] != 42 || values[164] != 87 || values[102] != 5 || values[16] != 6 || values[156] != 5 { 275 t.Fatalf("native stats: %v", values) 276 } 277 } 278 279 func TestControlRoutesRequireAdminPrefix(t *testing.T) { 280 world := &server{ 281 worldServices: worldServices{baseURL: "/"}} 282 handler := world.httpHandler() 283 284 for _, path := range []string{"users/1", "users", "items", "items/1", "time", "teleport/1", "map-players", "map-assets/manifest.json", "control-map.js"} { 285 response := httptest.NewRecorder() 286 handler.ServeHTTP(response, httptest.NewRequest("GET", "/"+path, nil)) 287 288 if response.Code != http.StatusNotFound { 289 t.Fatalf("unprefixed route %s: %d", path, response.Code) 290 } 291 } 292 } 293 294 func TestControlCharacterFormSavesNativeFieldsAndNamedSlots(t *testing.T) { 295 useNPCData(t, testNPCData()) 296 world := newTestServer(t) 297 postControlForm(world, "/admin/players", url.Values{"name": {"Explorer"}}) 298 for _, template := range []string{"121567", "85686", "101173"} { 299 postControlForm(world, "/admin/items", url.Values{"template": {template}}) 300 } 301 page := httptest.NewRecorder() 302 adminTestHandler(world).ServeHTTP(page, httptest.NewRequest("GET", "/admin/players/1", nil)) 303 fields := playerPageValues(t, page.Body.String()) 304 for name, value := range map[string]string{ 305 "name": "Edited", "position.x": "53", "position.y": "14", "position.z": "60", "appearance.head": "31", 306 "stats.improvement_points": "12345", "stats.ranged.rifle": "42", "vitals.health": "31", "inventory.credits": "913", 307 "inventory.slots.inventory_slot_7": "1", "equipment.clothes_chest": "2", "equipment.implants_chest": "3", 308 } { 309 fields.Set(name, value) 310 } 311 312 response := postControlForm(world, "/admin/players/1", fields) 313 restarted := newServerForTest(t) 314 var name string 315 var x float32 316 var head, points, rifle, health, credits uint32 317 err := restarted.db.QueryRow("SELECT name, position_x, appearance_head, improvement_points, ranged_rifle, health, credits FROM characters JOIN players USING(id) WHERE id=1").Scan(&name, &x, &head, &points, &rifle, &health, &credits) 318 319 if response.Code != http.StatusSeeOther || err != nil || name != "Edited" || x != 53 || head != 31 || points != 12345 || rifle != 42 || health != 31 || credits != 913 { 320 t.Fatalf("native character fields were not saved: %d %s, %v", response.Code, response.Body.String(), err) 321 } 322 if !strings.Contains(page.Body.String(), "<label>Breed<select") || !strings.Contains(page.Body.String(), ">Solitus (1)</option>") || !strings.Contains(page.Body.String(), "<label>Sex<select") || strings.Contains(page.Body.String(), "<textarea") { 323 t.Fatal("the form lost its named appearance choices") 324 } 325 if restarted.characters[1].appearance != 64277 || restarted.characters[1].position != [3]float32{53, 14, 60} || restarted.characters[1].inventory.Credits != 913 { 326 t.Fatal("the native row did not restore the edited character") 327 } 328 for _, placement := range [][2]uint32{{1, 70}, {2, 21}, {3, 37}} { 329 var slot uint32 330 if err := restarted.db.QueryRow("SELECT slot FROM item_locations WHERE item_id=? AND player_id=1", placement[0]).Scan(&slot); err != nil || slot != placement[1] { 331 t.Fatalf("named slot placement %v: slot %d, %v", placement, slot, err) 332 } 333 } 334 } 335 336 func TestControlCharacterFormRollsBackAllSections(t *testing.T) { 337 useNPCData(t, testNPCData()) 338 world := newTestServer(t) 339 postControlForm(world, "/admin/players", url.Values{"name": {"Explorer"}}) 340 postControlForm(world, "/admin/items", url.Values{"template": {"121567"}}) 341 postControlForm(world, "/admin/items", url.Values{"template": {"85557"}}) 342 if _, err := world.db.Exec("CREATE TRIGGER reject_editor BEFORE UPDATE OF name ON characters WHEN NEW.id=1 BEGIN SELECT RAISE(ABORT, 'write failed'); END"); err != nil { 343 t.Fatal(err) 344 } 345 contents := "name: Changed\nposition: [53, 14, 60]\ninventory:\n credits: 913\n slots: {inventory_slot_7: 1}\nequipment: {clothes_head: 2}\n" 346 347 response := postControlForm(world, "/admin/players/1", playerFixtureForm(contents)) 348 restarted := newServerForTest(t) 349 var name string 350 var credits, locations uint32 351 if err := restarted.db.QueryRow("SELECT name, credits FROM characters JOIN players USING(id) WHERE id=1").Scan(&name, &credits); err != nil { 352 t.Fatal(err) 353 } 354 if err := restarted.db.QueryRow("SELECT count(*) FROM item_locations").Scan(&locations); err != nil { 355 t.Fatal(err) 356 } 357 358 if response.Code != http.StatusInternalServerError || name != "Explorer" || credits != 0 || locations != 0 { 359 t.Fatalf("a rejected save committed part of the document: %d %s", response.Code, response.Body.String()) 360 } 361 if world.characters[1].name != "Explorer" || world.characters[1].position != [3]float32{52.625, 14.75, 56.875} || len(world.characters[1].inventory.Items) != 0 || 362 restarted.characters[1].position != [3]float32{52.625, 14.75, 56.875} { 363 t.Fatal("a rejected save changed the live or persisted character") 364 } 365 } 366 367 func TestControlAppearanceRejectsPackedScalarsAndOutOfRangeFields(t *testing.T) { 368 for _, contents := range []string{"appearance: 789\n", "appearance: {head: 32}\n", "appearance: {breed: 8}\n"} { 369 t.Run(contents, func(t *testing.T) { 370 useNPCData(t, testNPCData()) 371 world := newTestServer(t) 372 postControlForm(world, "/admin/players", url.Values{"name": {"Explorer"}}) 373 374 response := postControlForm(world, "/admin/players/1", playerFixtureForm(contents)) 375 376 if response.Code != http.StatusBadRequest || world.characters[1].appearance != 789 { 377 t.Fatalf("invalid appearance changed the character: %d %s", response.Code, response.Body.String()) 378 } 379 }) 380 } 381 } 382 383 func TestControlCharacterFormPreservesCastRefundAndExplicitNanoEdits(t *testing.T) { 384 for _, contents := range []string{"name: Edited\n", "name: Edited\nvitals: {nano: 13}\n"} { 385 t.Run(contents, func(t *testing.T) { 386 t.Chdir(t.TempDir()) 387 world, _ := newNanoCastingWorld(t) 388 world.baseURL = "/" 389 player, client := world.characters[1], world.clients[1] 390 if err := world.saveUser(player); err != nil { 391 t.Fatal(err) 392 } 393 defer world.closeDatabase() 394 world.handleNanoCast(client, characterActionPacket(1, [5]uint32{19, 50000, 1000000, 53019, 29618})[20:]) 395 396 response := postControlForm(world, "/admin/players/1", playerFixtureForm(contents)) 397 var nano, reserved uint32 398 err := world.db.QueryRow("SELECT nano,nano_reserved FROM characters WHERE id=1").Scan(&nano, &reserved) 399 400 expected := uint32(30) 401 if strings.Contains(contents, "nano: 13") { 402 expected = 13 403 } 404 if response.Code != http.StatusSeeOther || err != nil || nano != expected || reserved != 0 || player.nano != expected || player.nanoReserved != 0 || client.nanoCast != nil { 405 t.Fatalf("cast cancellation lost refund or explicit edit: %d, nano %d/%d, %v: %s", response.Code, nano, player.nano, err, response.Body.String()) 406 } 407 }) 408 } 409 }