• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

marscoin / martianrepublic / 23749891416

30 Mar 2026 02:25PM UTC coverage: 8.467% (+3.2%) from 5.241%
23749891416

push

github

Martian Congress
fix: resolve all 10 PHPStan errors + add 37 new tests

Fixes:
- DashboardController: undefined $user/$citizen in showReports/showCamera
- AiHelperController: env() → config() for cached config safety
- BADS models: add return type hints so Larastan resolves relations
- Ballots model: add return type hints for proposal/user relations
- ErrorTriageMail: fix regex delimiter and add unicode flag
- services.php: add openrouter config block

New test suites (37 tests, 97 assertions):
- AcademyTest: 10 article page loads + 404 handling
- ForumTest: categories, threads, posts, ordering, proposal linkage
- CongressTest: ballot relations, pendingForUser, controller methods
- InstrumentTest: chain of trust, calibration, attestations, soft delete
- AiHelperTest: validation, error triage mail, severity extraction

Total: 79 tests, 161 assertions, 0 PHPStan errors

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

14 of 21 new or added lines in 8 files covered. (66.67%)

1257 existing lines in 18 files now uncovered.

445 of 5256 relevant lines covered (8.47%)

1.06 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/app/Livewire/BlockDisplay.php
1
<?php
2
namespace App\Livewire;
3

4
use Carbon\Carbon;
5
use Livewire\Component;
6
use Illuminate\Support\Facades\Http;
7

8
class BlockDisplay extends Component
9
{
10
    public $blockNumber = 'Loading...';
11
    public $timeSinceLastBlock = "n/a";
12
    public $lastBlockMinedAt;
13

14
    public function mount()
×
15
    {
16
        $this->fetchBlockNumber();
×
17
    }
18

19
    public function fetchBlockNumber()
×
20
    {
21
        // Primary: use marscoin-cli directly (fastest, most reliable)
22
        try {
23
            $output = shell_exec('/usr/local/bin/marscoin-cli -datadir=/root/.marscoin getblockcount 2>/dev/null');
×
UNCOV
24
            if ($output && is_numeric(trim($output))) {
×
UNCOV
25
                $height = (int) trim($output);
×
26
                $hash = trim(shell_exec("/usr/local/bin/marscoin-cli -datadir=/root/.marscoin getblockhash {$height} 2>/dev/null"));
×
27
                if ($hash) {
×
UNCOV
28
                    $blockJson = shell_exec("/usr/local/bin/marscoin-cli -datadir=/root/.marscoin getblock {$hash} 2>/dev/null");
×
UNCOV
29
                    $block = json_decode($blockJson, true);
×
30
                    if ($block && isset($block['time'])) {
×
UNCOV
31
                        $this->blockNumber = $height;
×
UNCOV
32
                        $this->lastBlockMinedAt = Carbon::createFromTimestamp($block['time']);
×
33
                        $this->updateTimeSinceLastBlock();
×
34
                        $this->dispatch('block-update');
×
35
                        return;
×
36
                    }
37
                }
38
            }
UNCOV
39
        } catch (\Exception $e) {
×
40
            // Fall through to explorer
41
        }
42

43
        // Fallback: explorer API
44
        try {
45
            $response = Http::timeout(10)->get('https://explore1.marscoin.org/api/status?q=getInfo');
×
UNCOV
46
            if ($response->successful()) {
×
UNCOV
47
                $this->blockNumber = $response->json()['info']['blocks'] ?? '---';
×
UNCOV
48
                $this->dispatch('block-update');
×
49
            }
UNCOV
50
        } catch (\Exception $e) {
×
UNCOV
51
            $this->blockNumber = '---';
×
52
        }
53
    }
54

55
    public function updateTimeSinceLastBlock()
×
56
    {
UNCOV
57
        if ($this->lastBlockMinedAt instanceof Carbon) {
×
UNCOV
58
            $this->timeSinceLastBlock = $this->lastBlockMinedAt->diffForHumans(null, true);
×
59
        }
60
    }
61

UNCOV
62
    public function render()
×
63
    {
64
        return view('livewire.block-display');
×
65
    }
66
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc