Personal api unit test.

This commit is contained in:
sc0Vu 2018-01-05 17:01:08 +08:00
parent bdf87bdfb5
commit 5eed308ccd
2 changed files with 8 additions and 37 deletions

View File

@ -40,11 +40,7 @@ class PersonalApiTest extends TestCase
// infura banned us to use list accounts // infura banned us to use list accounts
return $this->assertTrue($err->getCode() === 405); return $this->assertTrue($err->getCode() === 405);
} }
if (isset($accounts->result)) { $this->assertTrue(is_array($accounts));
$this->assertTrue(is_array($accounts->result));
} else {
$this->fail($accounts->error->message);
}
}); });
} }
@ -62,11 +58,7 @@ class PersonalApiTest extends TestCase
// infura banned us to use new account // infura banned us to use new account
return $this->assertTrue($err->getCode() === 405); return $this->assertTrue($err->getCode() === 405);
} }
if (isset($account->result)) { $this->assertTrue(is_string($account));
$this->assertTrue(is_string($account->result));
} else {
$this->fail($account->error->message);
}
}); });
} }
@ -84,11 +76,7 @@ class PersonalApiTest extends TestCase
// infura banned us to use unlock account // infura banned us to use unlock account
return $this->assertTrue($err->getCode() === 405); return $this->assertTrue($err->getCode() === 405);
} }
if (isset($account->result)) { $this->assertTrue(is_bool($account));
$this->assertTrue(is_bool($account->result));
} else {
$this->fail($account->error->message);
}
}); });
} }
@ -113,16 +101,7 @@ class PersonalApiTest extends TestCase
// infura banned us to use send transaction // infura banned us to use send transaction
return $this->assertTrue($err->getCode() === 405); return $this->assertTrue($err->getCode() === 405);
} }
if (isset($transaction->result)) { $this->assertTrue(is_string($transaction));
$this->assertTrue(is_string($transaction->result));
} else {
if (isset($transaction->error)) {
// it's just test hex.
$this->assertTrue(is_string($transaction->error->message));
} else {
$this->assertTrue(true);
}
}
}); });
} }
@ -141,11 +120,7 @@ class PersonalApiTest extends TestCase
if ($err !== null) { if ($err !== null) {
return $this->fail($err->getMessage()); return $this->fail($err->getMessage());
} }
if (isset($hello->result)) { $this->assertTrue(true);
$this->assertTrue(true);
} else {
$this->fail($hello->error->message);
}
}); });
} }
@ -164,11 +139,7 @@ class PersonalApiTest extends TestCase
if ($err !== null) { if ($err !== null) {
return $this->fail($err->getMessage()); return $this->fail($err->getMessage());
} }
if (isset($account->result)) { $this->assertTrue(is_string($account));
$this->assertTrue(is_string($account->result));
} else {
$this->fail($account->error->message);
}
}); });
} }
} }

View File

@ -43,8 +43,8 @@ class PersonalBatchTest extends TestCase
if ($err !== null) { if ($err !== null) {
return $this->assertTrue($err->getCode() === 405); return $this->assertTrue($err->getCode() === 405);
} }
$this->assertTrue(is_array($data[0]->result)); $this->assertTrue(is_array($data[0]));
$this->assertTrue(is_string($data[1]->result)); $this->assertTrue(is_string($data[1]));
}); });
} }
} }