node_test.go 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644
  1. // Copyright 2015 The go-ethereum Authors
  2. // This file is part of the go-ethereum library.
  3. //
  4. // The go-ethereum library is free software: you can redistribute it and/or modify
  5. // it under the terms of the GNU Lesser General Public License as published by
  6. // the Free Software Foundation, either version 3 of the License, or
  7. // (at your option) any later version.
  8. //
  9. // The go-ethereum library is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU Lesser General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU Lesser General Public License
  15. // along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
  16. package node
  17. import (
  18. "errors"
  19. "fmt"
  20. "io"
  21. "io/ioutil"
  22. "net"
  23. "net/http"
  24. "os"
  25. "reflect"
  26. "strings"
  27. "testing"
  28. "github.com/ethereum/go-ethereum/crypto"
  29. "github.com/ethereum/go-ethereum/ethdb"
  30. "github.com/ethereum/go-ethereum/p2p"
  31. "github.com/ethereum/go-ethereum/rpc"
  32. "github.com/stretchr/testify/assert"
  33. )
  34. var (
  35. testNodeKey, _ = crypto.GenerateKey()
  36. )
  37. func testNodeConfig() *Config {
  38. return &Config{
  39. Name: "test node",
  40. P2P: p2p.Config{PrivateKey: testNodeKey},
  41. }
  42. }
  43. // Tests that an empty protocol stack can be closed more than once.
  44. func TestNodeCloseMultipleTimes(t *testing.T) {
  45. stack, err := New(testNodeConfig())
  46. if err != nil {
  47. t.Fatalf("failed to create protocol stack: %v", err)
  48. }
  49. stack.Close()
  50. // Ensure that a stopped node can be stopped again
  51. for i := 0; i < 3; i++ {
  52. if err := stack.Close(); err != ErrNodeStopped {
  53. t.Fatalf("iter %d: stop failure mismatch: have %v, want %v", i, err, ErrNodeStopped)
  54. }
  55. }
  56. }
  57. func TestNodeStartMultipleTimes(t *testing.T) {
  58. stack, err := New(testNodeConfig())
  59. if err != nil {
  60. t.Fatalf("failed to create protocol stack: %v", err)
  61. }
  62. // Ensure that a node can be successfully started, but only once
  63. if err := stack.Start(); err != nil {
  64. t.Fatalf("failed to start node: %v", err)
  65. }
  66. if err := stack.Start(); err != ErrNodeRunning {
  67. t.Fatalf("start failure mismatch: have %v, want %v ", err, ErrNodeRunning)
  68. }
  69. // Ensure that a node can be stopped, but only once
  70. if err := stack.Close(); err != nil {
  71. t.Fatalf("failed to stop node: %v", err)
  72. }
  73. if err := stack.Close(); err != ErrNodeStopped {
  74. t.Fatalf("stop failure mismatch: have %v, want %v ", err, ErrNodeStopped)
  75. }
  76. }
  77. // Tests that if the data dir is already in use, an appropriate error is returned.
  78. func TestNodeUsedDataDir(t *testing.T) {
  79. // Create a temporary folder to use as the data directory
  80. dir, err := ioutil.TempDir("", "")
  81. if err != nil {
  82. t.Fatalf("failed to create temporary data directory: %v", err)
  83. }
  84. defer os.RemoveAll(dir)
  85. // Create a new node based on the data directory
  86. original, err := New(&Config{DataDir: dir})
  87. if err != nil {
  88. t.Fatalf("failed to create original protocol stack: %v", err)
  89. }
  90. defer original.Close()
  91. if err := original.Start(); err != nil {
  92. t.Fatalf("failed to start original protocol stack: %v", err)
  93. }
  94. // Create a second node based on the same data directory and ensure failure
  95. _, err = New(&Config{DataDir: dir})
  96. if err != ErrDatadirUsed {
  97. t.Fatalf("duplicate datadir failure mismatch: have %v, want %v", err, ErrDatadirUsed)
  98. }
  99. }
  100. // Tests whether a Lifecycle can be registered.
  101. func TestLifecycleRegistry_Successful(t *testing.T) {
  102. stack, err := New(testNodeConfig())
  103. if err != nil {
  104. t.Fatalf("failed to create protocol stack: %v", err)
  105. }
  106. defer stack.Close()
  107. noop := NewNoop()
  108. stack.RegisterLifecycle(noop)
  109. if !containsLifecycle(stack.lifecycles, noop) {
  110. t.Fatalf("lifecycle was not properly registered on the node, %v", err)
  111. }
  112. }
  113. // Tests whether a service's protocols can be registered properly on the node's p2p server.
  114. func TestRegisterProtocols(t *testing.T) {
  115. stack, err := New(testNodeConfig())
  116. if err != nil {
  117. t.Fatalf("failed to create protocol stack: %v", err)
  118. }
  119. defer stack.Close()
  120. fs, err := NewFullService(stack)
  121. if err != nil {
  122. t.Fatalf("could not create full service: %v", err)
  123. }
  124. for _, protocol := range fs.Protocols() {
  125. if !containsProtocol(stack.server.Protocols, protocol) {
  126. t.Fatalf("protocol %v was not successfully registered", protocol)
  127. }
  128. }
  129. for _, api := range fs.APIs() {
  130. if !containsAPI(stack.rpcAPIs, api) {
  131. t.Fatalf("api %v was not successfully registered", api)
  132. }
  133. }
  134. }
  135. // This test checks that open databases are closed with node.
  136. func TestNodeCloseClosesDB(t *testing.T) {
  137. stack, _ := New(testNodeConfig())
  138. defer stack.Close()
  139. db, err := stack.OpenDatabase("mydb", 0, 0, "", false)
  140. if err != nil {
  141. t.Fatal("can't open DB:", err)
  142. }
  143. if err = db.Put([]byte{}, []byte{}); err != nil {
  144. t.Fatal("can't Put on open DB:", err)
  145. }
  146. stack.Close()
  147. if err = db.Put([]byte{}, []byte{}); err == nil {
  148. t.Fatal("Put succeeded after node is closed")
  149. }
  150. }
  151. // This test checks that OpenDatabase can be used from within a Lifecycle Start method.
  152. func TestNodeOpenDatabaseFromLifecycleStart(t *testing.T) {
  153. stack, _ := New(testNodeConfig())
  154. defer stack.Close()
  155. var db ethdb.Database
  156. var err error
  157. stack.RegisterLifecycle(&InstrumentedService{
  158. startHook: func() {
  159. db, err = stack.OpenDatabase("mydb", 0, 0, "", false)
  160. if err != nil {
  161. t.Fatal("can't open DB:", err)
  162. }
  163. },
  164. stopHook: func() {
  165. db.Close()
  166. },
  167. })
  168. stack.Start()
  169. stack.Close()
  170. }
  171. // This test checks that OpenDatabase can be used from within a Lifecycle Stop method.
  172. func TestNodeOpenDatabaseFromLifecycleStop(t *testing.T) {
  173. stack, _ := New(testNodeConfig())
  174. defer stack.Close()
  175. stack.RegisterLifecycle(&InstrumentedService{
  176. stopHook: func() {
  177. db, err := stack.OpenDatabase("mydb", 0, 0, "", false)
  178. if err != nil {
  179. t.Fatal("can't open DB:", err)
  180. }
  181. db.Close()
  182. },
  183. })
  184. stack.Start()
  185. stack.Close()
  186. }
  187. // Tests that registered Lifecycles get started and stopped correctly.
  188. func TestLifecycleLifeCycle(t *testing.T) {
  189. stack, _ := New(testNodeConfig())
  190. defer stack.Close()
  191. started := make(map[string]bool)
  192. stopped := make(map[string]bool)
  193. // Create a batch of instrumented services
  194. lifecycles := map[string]Lifecycle{
  195. "A": &InstrumentedService{
  196. startHook: func() { started["A"] = true },
  197. stopHook: func() { stopped["A"] = true },
  198. },
  199. "B": &InstrumentedService{
  200. startHook: func() { started["B"] = true },
  201. stopHook: func() { stopped["B"] = true },
  202. },
  203. "C": &InstrumentedService{
  204. startHook: func() { started["C"] = true },
  205. stopHook: func() { stopped["C"] = true },
  206. },
  207. }
  208. // register lifecycles on node
  209. for _, lifecycle := range lifecycles {
  210. stack.RegisterLifecycle(lifecycle)
  211. }
  212. // Start the node and check that all services are running
  213. if err := stack.Start(); err != nil {
  214. t.Fatalf("failed to start protocol stack: %v", err)
  215. }
  216. for id := range lifecycles {
  217. if !started[id] {
  218. t.Fatalf("service %s: freshly started service not running", id)
  219. }
  220. if stopped[id] {
  221. t.Fatalf("service %s: freshly started service already stopped", id)
  222. }
  223. }
  224. // Stop the node and check that all services have been stopped
  225. if err := stack.Close(); err != nil {
  226. t.Fatalf("failed to stop protocol stack: %v", err)
  227. }
  228. for id := range lifecycles {
  229. if !stopped[id] {
  230. t.Fatalf("service %s: freshly terminated service still running", id)
  231. }
  232. }
  233. }
  234. // Tests that if a Lifecycle fails to start, all others started before it will be
  235. // shut down.
  236. func TestLifecycleStartupError(t *testing.T) {
  237. stack, err := New(testNodeConfig())
  238. if err != nil {
  239. t.Fatalf("failed to create protocol stack: %v", err)
  240. }
  241. defer stack.Close()
  242. started := make(map[string]bool)
  243. stopped := make(map[string]bool)
  244. // Create a batch of instrumented services
  245. lifecycles := map[string]Lifecycle{
  246. "A": &InstrumentedService{
  247. startHook: func() { started["A"] = true },
  248. stopHook: func() { stopped["A"] = true },
  249. },
  250. "B": &InstrumentedService{
  251. startHook: func() { started["B"] = true },
  252. stopHook: func() { stopped["B"] = true },
  253. },
  254. "C": &InstrumentedService{
  255. startHook: func() { started["C"] = true },
  256. stopHook: func() { stopped["C"] = true },
  257. },
  258. }
  259. // register lifecycles on node
  260. for _, lifecycle := range lifecycles {
  261. stack.RegisterLifecycle(lifecycle)
  262. }
  263. // Register a service that fails to construct itself
  264. failure := errors.New("fail")
  265. failer := &InstrumentedService{start: failure}
  266. stack.RegisterLifecycle(failer)
  267. // Start the protocol stack and ensure all started services stop
  268. if err := stack.Start(); err != failure {
  269. t.Fatalf("stack startup failure mismatch: have %v, want %v", err, failure)
  270. }
  271. for id := range lifecycles {
  272. if started[id] && !stopped[id] {
  273. t.Fatalf("service %s: started but not stopped", id)
  274. }
  275. delete(started, id)
  276. delete(stopped, id)
  277. }
  278. }
  279. // Tests that even if a registered Lifecycle fails to shut down cleanly, it does
  280. // not influence the rest of the shutdown invocations.
  281. func TestLifecycleTerminationGuarantee(t *testing.T) {
  282. stack, err := New(testNodeConfig())
  283. if err != nil {
  284. t.Fatalf("failed to create protocol stack: %v", err)
  285. }
  286. defer stack.Close()
  287. started := make(map[string]bool)
  288. stopped := make(map[string]bool)
  289. // Create a batch of instrumented services
  290. lifecycles := map[string]Lifecycle{
  291. "A": &InstrumentedService{
  292. startHook: func() { started["A"] = true },
  293. stopHook: func() { stopped["A"] = true },
  294. },
  295. "B": &InstrumentedService{
  296. startHook: func() { started["B"] = true },
  297. stopHook: func() { stopped["B"] = true },
  298. },
  299. "C": &InstrumentedService{
  300. startHook: func() { started["C"] = true },
  301. stopHook: func() { stopped["C"] = true },
  302. },
  303. }
  304. // register lifecycles on node
  305. for _, lifecycle := range lifecycles {
  306. stack.RegisterLifecycle(lifecycle)
  307. }
  308. // Register a service that fails to shot down cleanly
  309. failure := errors.New("fail")
  310. failer := &InstrumentedService{stop: failure}
  311. stack.RegisterLifecycle(failer)
  312. // Start the protocol stack, and ensure that a failing shut down terminates all
  313. // Start the stack and make sure all is online
  314. if err := stack.Start(); err != nil {
  315. t.Fatalf("failed to start protocol stack: %v", err)
  316. }
  317. for id := range lifecycles {
  318. if !started[id] {
  319. t.Fatalf("service %s: service not running", id)
  320. }
  321. if stopped[id] {
  322. t.Fatalf("service %s: service already stopped", id)
  323. }
  324. }
  325. // Stop the stack, verify failure and check all terminations
  326. err = stack.Close()
  327. if err, ok := err.(*StopError); !ok {
  328. t.Fatalf("termination failure mismatch: have %v, want StopError", err)
  329. } else {
  330. failer := reflect.TypeOf(&InstrumentedService{})
  331. if err.Services[failer] != failure {
  332. t.Fatalf("failer termination failure mismatch: have %v, want %v", err.Services[failer], failure)
  333. }
  334. if len(err.Services) != 1 {
  335. t.Fatalf("failure count mismatch: have %d, want %d", len(err.Services), 1)
  336. }
  337. }
  338. for id := range lifecycles {
  339. if !stopped[id] {
  340. t.Fatalf("service %s: service not terminated", id)
  341. }
  342. delete(started, id)
  343. delete(stopped, id)
  344. }
  345. stack.server = &p2p.Server{}
  346. stack.server.PrivateKey = testNodeKey
  347. }
  348. // Tests whether a handler can be successfully mounted on the canonical HTTP server
  349. // on the given prefix
  350. func TestRegisterHandler_Successful(t *testing.T) {
  351. node := createNode(t, 7878, 7979)
  352. // create and mount handler
  353. handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
  354. w.Write([]byte("success"))
  355. })
  356. node.RegisterHandler("test", "/test", handler)
  357. // start node
  358. if err := node.Start(); err != nil {
  359. t.Fatalf("could not start node: %v", err)
  360. }
  361. // create HTTP request
  362. httpReq, err := http.NewRequest(http.MethodGet, "http://127.0.0.1:7878/test", nil)
  363. if err != nil {
  364. t.Error("could not issue new http request ", err)
  365. }
  366. // check response
  367. resp := doHTTPRequest(t, httpReq)
  368. buf := make([]byte, 7)
  369. _, err = io.ReadFull(resp.Body, buf)
  370. if err != nil {
  371. t.Fatalf("could not read response: %v", err)
  372. }
  373. assert.Equal(t, "success", string(buf))
  374. }
  375. // Tests that the given handler will not be successfully mounted since no HTTP server
  376. // is enabled for RPC
  377. func TestRegisterHandler_Unsuccessful(t *testing.T) {
  378. node, err := New(&DefaultConfig)
  379. if err != nil {
  380. t.Fatalf("could not create new node: %v", err)
  381. }
  382. // create and mount handler
  383. handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
  384. w.Write([]byte("success"))
  385. })
  386. node.RegisterHandler("test", "/test", handler)
  387. }
  388. // Tests whether websocket requests can be handled on the same port as a regular http server.
  389. func TestWebsocketHTTPOnSamePort_WebsocketRequest(t *testing.T) {
  390. node := startHTTP(t, 0, 0)
  391. defer node.Close()
  392. ws := strings.Replace(node.HTTPEndpoint(), "http://", "ws://", 1)
  393. if node.WSEndpoint() != ws {
  394. t.Fatalf("endpoints should be the same")
  395. }
  396. if !checkRPC(ws) {
  397. t.Fatalf("ws request failed")
  398. }
  399. if !checkRPC(node.HTTPEndpoint()) {
  400. t.Fatalf("http request failed")
  401. }
  402. }
  403. func TestWebsocketHTTPOnSeparatePort_WSRequest(t *testing.T) {
  404. // try and get a free port
  405. listener, err := net.Listen("tcp", "127.0.0.1:0")
  406. if err != nil {
  407. t.Fatal("can't listen:", err)
  408. }
  409. port := listener.Addr().(*net.TCPAddr).Port
  410. listener.Close()
  411. node := startHTTP(t, 0, port)
  412. defer node.Close()
  413. wsOnHTTP := strings.Replace(node.HTTPEndpoint(), "http://", "ws://", 1)
  414. ws := fmt.Sprintf("ws://127.0.0.1:%d", port)
  415. if node.WSEndpoint() == wsOnHTTP {
  416. t.Fatalf("endpoints should not be the same")
  417. }
  418. // ensure ws endpoint matches the expected endpoint
  419. if node.WSEndpoint() != ws {
  420. t.Fatalf("ws endpoint is incorrect: expected %s, got %s", ws, node.WSEndpoint())
  421. }
  422. if !checkRPC(ws) {
  423. t.Fatalf("ws request failed")
  424. }
  425. if !checkRPC(node.HTTPEndpoint()) {
  426. t.Fatalf("http request failed")
  427. }
  428. }
  429. type rpcPrefixTest struct {
  430. httpPrefix, wsPrefix string
  431. // These lists paths on which JSON-RPC should be served / not served.
  432. wantHTTP []string
  433. wantNoHTTP []string
  434. wantWS []string
  435. wantNoWS []string
  436. }
  437. func TestNodeRPCPrefix(t *testing.T) {
  438. t.Parallel()
  439. tests := []rpcPrefixTest{
  440. // both off
  441. {
  442. httpPrefix: "", wsPrefix: "",
  443. wantHTTP: []string{"/", "/?p=1"},
  444. wantNoHTTP: []string{"/test", "/test?p=1"},
  445. wantWS: []string{"/", "/?p=1"},
  446. wantNoWS: []string{"/test", "/test?p=1"},
  447. },
  448. // only http prefix
  449. {
  450. httpPrefix: "/testprefix", wsPrefix: "",
  451. wantHTTP: []string{"/testprefix", "/testprefix?p=1", "/testprefix/x", "/testprefix/x?p=1"},
  452. wantNoHTTP: []string{"/", "/?p=1", "/test", "/test?p=1"},
  453. wantWS: []string{"/", "/?p=1"},
  454. wantNoWS: []string{"/testprefix", "/testprefix?p=1", "/test", "/test?p=1"},
  455. },
  456. // only ws prefix
  457. {
  458. httpPrefix: "", wsPrefix: "/testprefix",
  459. wantHTTP: []string{"/", "/?p=1"},
  460. wantNoHTTP: []string{"/testprefix", "/testprefix?p=1", "/test", "/test?p=1"},
  461. wantWS: []string{"/testprefix", "/testprefix?p=1", "/testprefix/x", "/testprefix/x?p=1"},
  462. wantNoWS: []string{"/", "/?p=1", "/test", "/test?p=1"},
  463. },
  464. // both set
  465. {
  466. httpPrefix: "/testprefix", wsPrefix: "/testprefix",
  467. wantHTTP: []string{"/testprefix", "/testprefix?p=1", "/testprefix/x", "/testprefix/x?p=1"},
  468. wantNoHTTP: []string{"/", "/?p=1", "/test", "/test?p=1"},
  469. wantWS: []string{"/testprefix", "/testprefix?p=1", "/testprefix/x", "/testprefix/x?p=1"},
  470. wantNoWS: []string{"/", "/?p=1", "/test", "/test?p=1"},
  471. },
  472. }
  473. for _, test := range tests {
  474. test := test
  475. name := fmt.Sprintf("http=%s ws=%s", test.httpPrefix, test.wsPrefix)
  476. t.Run(name, func(t *testing.T) {
  477. cfg := &Config{
  478. HTTPHost: "127.0.0.1",
  479. HTTPPathPrefix: test.httpPrefix,
  480. WSHost: "127.0.0.1",
  481. WSPathPrefix: test.wsPrefix,
  482. }
  483. node, err := New(cfg)
  484. if err != nil {
  485. t.Fatal("can't create node:", err)
  486. }
  487. defer node.Close()
  488. if err := node.Start(); err != nil {
  489. t.Fatal("can't start node:", err)
  490. }
  491. test.check(t, node)
  492. })
  493. }
  494. }
  495. func (test rpcPrefixTest) check(t *testing.T, node *Node) {
  496. t.Helper()
  497. httpBase := "http://" + node.http.listenAddr()
  498. wsBase := "ws://" + node.http.listenAddr()
  499. if node.WSEndpoint() != wsBase+test.wsPrefix {
  500. t.Errorf("Error: node has wrong WSEndpoint %q", node.WSEndpoint())
  501. }
  502. for _, path := range test.wantHTTP {
  503. resp := rpcRequest(t, httpBase+path)
  504. if resp.StatusCode != 200 {
  505. t.Errorf("Error: %s: bad status code %d, want 200", path, resp.StatusCode)
  506. }
  507. }
  508. for _, path := range test.wantNoHTTP {
  509. resp := rpcRequest(t, httpBase+path)
  510. if resp.StatusCode != 404 {
  511. t.Errorf("Error: %s: bad status code %d, want 404", path, resp.StatusCode)
  512. }
  513. }
  514. for _, path := range test.wantWS {
  515. err := wsRequest(t, wsBase+path, "")
  516. if err != nil {
  517. t.Errorf("Error: %s: WebSocket connection failed: %v", path, err)
  518. }
  519. }
  520. for _, path := range test.wantNoWS {
  521. err := wsRequest(t, wsBase+path, "")
  522. if err == nil {
  523. t.Errorf("Error: %s: WebSocket connection succeeded for path in wantNoWS", path)
  524. }
  525. }
  526. }
  527. func createNode(t *testing.T, httpPort, wsPort int) *Node {
  528. conf := &Config{
  529. HTTPHost: "127.0.0.1",
  530. HTTPPort: httpPort,
  531. WSHost: "127.0.0.1",
  532. WSPort: wsPort,
  533. }
  534. node, err := New(conf)
  535. if err != nil {
  536. t.Fatalf("could not create a new node: %v", err)
  537. }
  538. return node
  539. }
  540. func startHTTP(t *testing.T, httpPort, wsPort int) *Node {
  541. node := createNode(t, httpPort, wsPort)
  542. err := node.Start()
  543. if err != nil {
  544. t.Fatalf("could not start http service on node: %v", err)
  545. }
  546. return node
  547. }
  548. func doHTTPRequest(t *testing.T, req *http.Request) *http.Response {
  549. client := http.DefaultClient
  550. resp, err := client.Do(req)
  551. if err != nil {
  552. t.Fatalf("could not issue a GET request to the given endpoint: %v", err)
  553. }
  554. return resp
  555. }
  556. func containsProtocol(stackProtocols []p2p.Protocol, protocol p2p.Protocol) bool {
  557. for _, a := range stackProtocols {
  558. if reflect.DeepEqual(a, protocol) {
  559. return true
  560. }
  561. }
  562. return false
  563. }
  564. func containsAPI(stackAPIs []rpc.API, api rpc.API) bool {
  565. for _, a := range stackAPIs {
  566. if reflect.DeepEqual(a, api) {
  567. return true
  568. }
  569. }
  570. return false
  571. }