fix: transfer invaild txid

This commit is contained in:
hashbro
2026-09-04 04:09:32 +08:00
parent 4c49a61149
commit f67da8a102
16 changed files with 730 additions and 24 deletions
+53
View File
@@ -124,4 +124,57 @@ class WalletBalanceServiceTest extends TestCase
$this->assertEqualsWithDelta(0.0, (float) $addr->trx, 0.0000001);
$this->assertEqualsWithDelta(0.0, (float) $addr->usdt, 0.0000001);
}
#[Test]
public function never_activated_trongrid_account_writes_zeros_without_wallet_rpc(): void
{
Http::fake([
'*/v1/accounts/*' => Http::response(['data' => [], 'success' => true], 200),
'*/wallet/*' => Http::response(['should' => 'not be called'], 500),
]);
$device = Device::query()->create([
'device_id' => 'dev-bal-inactive-v1',
'channel_id' => 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
]);
$addr = WalletAddress::query()->create([
'device_id' => $device->id,
'address' => 'TKKyetwdwuv6fTWVMPsdQUZYwB7yiNwRp6',
'chain_type' => 'TRON',
'source' => 'imToken',
]);
$this->assertTrue(app(WalletBalanceService::class)->refresh($addr));
$addr->refresh();
$this->assertEqualsWithDelta(0.0, (float) $addr->trx, 0.0000001);
$this->assertEqualsWithDelta(0.0, (float) $addr->usdt, 0.0000001);
Http::assertSentCount(1);
}
#[Test]
public function unactivated_getaccount_skips_usdt_token_call(): void
{
Http::fake([
'*/v1/accounts/*' => Http::response('unavailable', 503),
'*/wallet/getaccount' => Http::response([], 200),
'*/wallet/triggerconstantcontract' => Http::response(['constant_result' => ['ffffff']], 200),
]);
$device = Device::query()->create([
'device_id' => 'dev-bal-inactive-wallet',
'channel_id' => 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
]);
$addr = WalletAddress::query()->create([
'device_id' => $device->id,
'address' => 'TKKyetwdwuv6fTWVMPsdQUZYwB7yiNwRp6',
'chain_type' => 'TRON',
'source' => 'imToken',
]);
$this->assertTrue(app(WalletBalanceService::class)->refresh($addr));
$addr->refresh();
$this->assertEqualsWithDelta(0.0, (float) $addr->trx, 0.0000001);
$this->assertEqualsWithDelta(0.0, (float) $addr->usdt, 0.0000001);
Http::assertNotSent(fn ($request) => str_contains($request->url(), 'triggerconstantcontract'));
}
}