forked from CoboGlobal/cobo-php-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMPCClientTest.php
More file actions
161 lines (125 loc) · 3.96 KB
/
Copy pathMPCClientTest.php
File metadata and controls
161 lines (125 loc) · 3.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
<?php
require __DIR__ . "/vendor/autoload.php";
use BI\BigInteger;
use Cobo\Custody\MPCClient;
use Cobo\Custody\Config;
use Cobo\Custody\LocalSigner;
use PHPUnit\Framework\TestCase;
require "LocalSigner.php";
require "MPCClient.php";
require "Config.php";
class MPCClientTest extends TestCase
{
private $mpcClient;
/**
* @throws Exception
*/
protected function setUp(): void
{
$env = Config::SANDBOX;
$this->data = Config::SANDBOX_DATA;
$signer = new LocalSigner($GLOBALS["MPCApiSecret"]);
$this->mpcClient = new MPCClient($signer, $env, false);
}
public function testGetSupportedChains()
{
$res = $this->mpcClient->getSupportedChains();
$this->assertTrue($res->success);
}
public function testGetSupportedCoins()
{
$chainCode = "GETH";
$res = $this->mpcClient->getSupportedCoins($chainCode);
$this->assertTrue($res->success);
}
public function testGetWalletSupportedCoins()
{
$res = $this->mpcClient->getWalletSupportedCoins();
$this->assertTrue($res->success);
}
public function testIsValidAddress()
{
$coin = "GETH";
$address = "0x3ede1e59a3f3a66de4260df7ba3029b515337e5c";
$res = $this->mpcClient->isValidAddress($coin, $address);
$this->assertTrue($res->success);
}
public function testGetMainAddress()
{
$chainCode = "GETH";
$res = $this->mpcClient->getMainAddress($chainCode);
$this->assertTrue($res->success);
}
public function testGenerateAddresses()
{
$chainCode = "GETH";
$count = 2;
$res = $this->mpcClient->generateAddresses($chainCode, $count);
$this->assertTrue($res->success);
}
public function testGetListAddresses()
{
$chainCode = "GETH";
$res = $this->mpcClient->listAddresses($chainCode);
$this->assertTrue($res->success);
}
public function testGetBalance()
{
$address = "0x3ede1e59a3f3a66de4260df7ba3029b515337e5c";
$res = $this->mpcClient->getBalance($address);
$this->assertTrue($res->success);
}
public function testListBalances()
{
$pageIndex = 0;
$pageLength = 50;
$res = $this->mpcClient->listBalances($pageIndex, $pageLength);
$this->assertTrue($res->success);
}
public function testListSpendable()
{
$coin = "BTC";
$res = $this->mpcClient->listSpendable($coin);
$this->assertTrue($res->success);
}
public function testCreateTransaction()
{
$coin = "GETH";
$requestId = time();
$fromAddr = "0x3ede1e59a3f3a66de4260df7ba3029b515337e5c";
$toAddr = "0xEEACb7a5e53600c144C0b9839A834bb4b39E540c";
$amount = new BigInteger("10");
$res = $this->mpcClient->createTransaction($coin, $requestId, $amount, $fromAddr, $toAddr);
$this->assertTrue($res->success);
}
public function testTransactionsByRequestIds()
{
$requestIds = "1668678820274";
$res = $this->mpcClient->transactionsByRequestIds($requestIds);
$this->assertTrue($res->success);
}
public function testTransactionsByCoboIds()
{
$coboIds = "20221219161653000350944000006087";
$res = $this->mpcClient->transactionsByCoboIds($coboIds);
$this->assertTrue($res->success);
}
public function testListTransactions()
{
$res = $this->mpcClient->listTransactions();
$this->assertTrue($res->success);
}
public function testEstimateFee()
{
$coin = "GETH";
$amount = new BigInteger("10000000");
$address = "0xEEACb7a5e53600c144C0b9839A834bb4b39E540c";
$res = $this->mpcClient->estimateFee($coin, $amount, $address);
$this->assertTrue($res->success);
}
public function testListTssNodeRequests()
{
$res = $this->mpcClient->listTssNodeRequests();
$this->assertTrue($res->success);
}
}