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

marscoin / martianrepublic / 23751722506

30 Mar 2026 03:03PM UTC coverage: 8.391% (-0.01%) from 8.401%
23751722506

push

github

Martian Congress
refactor: Sprint 2 — architecture cleanup (A3, A4, A7, A9)

A3: Added $fillable to 7 models (Proposals, Vote, Threads, HDWallet,
    IPFSRoot, Publication, Voucher) — closes mass assignment risk

A4: Created config/blockchain.php centralizing all hardcoded URLs
    (RPC, Pebas, IPFS, Explorer, Ballot, Price). Updated 7 files
    to use config() instead of hardcoded strings.

A7: Removed dead code:
    - Deleted ApiController.php.bak, AppHelper.php.bak
    - Deleted unused models: Pkimport.php, Recovery.php
    - Deleted resources/views/wallet/testing.html
    - Removed 8 commented-out routes from web.php and api.php

A9: Added performance indexes migration:
    - proposals.status (phase sync, tab filtering)
    - ballots.userid, ballots.proposalid, ballots(userid,status)
    - votes.proposal_id (vote tallying)
    - forum_posts.author_id, forum_threads.author_id (joins)

A1 (controller split) deferred to dedicated session — too much
in-page JS coupling to batch safely.

79 tests passing, 0 PHPStan errors.

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

2 of 48 new or added lines in 7 files covered. (4.17%)

2 existing lines in 2 files now uncovered.

445 of 5303 relevant lines covered (8.39%)

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
use Illuminate\Support\Facades\Process;
8

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

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

20
    public function fetchBlockNumber()
×
21
    {
NEW
22
        $cli = config('blockchain.rpc.cli_path');
×
NEW
23
        $dataDir = config('blockchain.rpc.data_dir');
×
24

25
        try {
NEW
26
            $result = Process::timeout(10)->run([$cli, '-datadir=' . $dataDir, 'getblockcount']);
×
27
            if ($result->successful() && is_numeric(trim($result->output()))) {
×
28
                $height = (int) trim($result->output());
×
29

NEW
30
                $result = Process::timeout(10)->run([$cli, '-datadir=' . $dataDir, 'getblockhash', (string) $height]);
×
31
                $hash = trim($result->output());
×
32
                if ($result->successful() && $hash) {
×
NEW
33
                    $result = Process::timeout(10)->run([$cli, '-datadir=' . $dataDir, 'getblock', $hash]);
×
34
                    $block = json_decode($result->output(), true);
×
35
                    if ($block && isset($block['time'])) {
×
36
                        $this->blockNumber = $height;
×
37
                        $this->lastBlockMinedAt = Carbon::createFromTimestamp($block['time']);
×
38
                        $this->updateTimeSinceLastBlock();
×
39
                        $this->dispatch('block-update');
×
40
                        return;
×
41
                    }
42
                }
43
            }
44
        } catch (\Exception $e) {
×
45
            // Fall through to explorer
46
        }
47

48
        // Fallback: explorer API
49
        try {
NEW
50
            $response = Http::timeout(10)->get(config('blockchain.explorer.fallback_url') . '/api/status?q=getInfo');
×
51
            if ($response->successful()) {
×
52
                $this->blockNumber = $response->json()['info']['blocks'] ?? '---';
×
53
                $this->dispatch('block-update');
×
54
            }
55
        } catch (\Exception $e) {
×
56
            $this->blockNumber = '---';
×
57
        }
58
    }
59

60
    public function updateTimeSinceLastBlock()
×
61
    {
62
        if ($this->lastBlockMinedAt instanceof Carbon) {
×
63
            $this->timeSinceLastBlock = $this->lastBlockMinedAt->diffForHumans(null, true);
×
64
        }
65
    }
66

67
    public function render()
×
68
    {
69
        return view('livewire.block-display');
×
70
    }
71
}
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