Mock the SellerMagnet API in Perl tests by generalizing the Perl quickstart's own documented new(base => ...) test seam into a per-test scriptable fake: FakeServer.pm forks a real local HTTP::Daemon for each test and lets it script exactly the response it needs, while SellerMagnet.pm and SellerMagnet::Retry run completely unmodified against it. No credit is spent, no request leaves localhost, and nothing beyond core Perl plus the quickstart's own libwww-perl dependency is required - not even a CPAN mocking library.
Key Takeaways
- The Perl quickstart's own SellerMagnet.pm already documents
base => .../SELLERMAGNET_API_BASEas a test-only seam; FakeServer.pm only generalizes it into a per-test scriptable local server. - Perl's ithreads clone the whole interpreter on create, so a route installed in the main thread is invisible to a server thread. fork() instead inherits the already-bound listening socket, so a child process can serve the fake without any shared memory.
- Make the fake fail closed: a request before a test installs its route gets a 500 "no route installed" answer - and since a 500 is refunded-and-retried-once by SellerMagnet::Retry, the fake must expect that second call too.
- A 429 is free and worth waiting out for real; a refunded 500 is worth one retry; a 502/503 is billed on every attempt, so cap the attempts.
- This suite does not shrink SellerMagnet::Retry's backoff, so the 429/500/502 tests take real seconds - proof the actual wait and Retry-After handling work.
Why not just call the real API in a Perl test suite?
Every SellerMagnet API request is billed per the table below, whether it comes from production code or a test run. A CI run that fires on every push would spend credits on every build, and a 429 or a second consecutive 500 cannot be forced on demand against the live API at all. A fake server makes every status code in the table, including the rare ones, reproducible on every run.
| Scenario | Charged | Retry? | Client should |
|---|---|---|---|
| happy path lookup | billed | no | decode, 1 credit |
| lookup, no featured offer ("N/A") | billed | no | price stays the string "N/A", never 0 |
| 404 product not found | billed | no | record it; never retry |
| free gate 400 (missing marketplaceId) | free | no | fix the request, no retry |
| endpoint 400 ("Invalid product ASIN") | billed | no | fix the call; this one IS charged |
| 401 invalid key | free | no | stop; fix the key |
| 429 concurrency cap | free | yes | wait Retry-After, then retry |
| 500 internal error | refunded | yes | retry once, then stop |
| 502 / 503 upstream | billed | yes | retry up to the attempt cap |
How do I fake just the server, not my own code?
SellerMagnet->new's constructor already takes a base argument (or reads SELLERMAGNET_API_BASE), the exact seam its own source comments document as test-only. FakeServer.pm generalizes that into something a test suite can script per scenario: it creates the HTTP::Daemon socket in the PARENT process (so the base URL is known at once), then run_in_child(route, n) forks a child that serves exactly n scripted responses and exits. Call counts cross the fork boundary through a tiny flock-guarded counter file instead of shared memory, so a test can still assert "called exactly once" after the child exits. get_once(), get_with_retry() and SellerMagnet::ApiError (all from the Perl quickstart) run exactly as they would in production.

FakeServer.pm - forks a real local HTTP::Daemon per test, fails closed
package FakeServer;
use strict;
use warnings;
use HTTP::Daemon;
use Fcntl qw(:flock);
# Generalizes the quickstart's own documented test seam (SellerMagnet->new(base => ...) /
# SELLERMAGNET_API_BASE) into a per-test scriptable fake backed by a REAL local HTTP::Daemon
# server. The daemon socket is created and bound in the PARENT process (so base() is known
# immediately); run_in_child(route, n) THEN forks a child that serves exactly n requests with
# that route and exits, while the parent calls SellerMagnet.pm / SellerMagnet::Retry completely
# unchanged against base(). A plain in-process closure cannot survive an exec() into a new
# process, but fork() duplicates the WHOLE interpreter (not just the socket), so the route
# closure installed before fork is simply inherited into the child unchanged - no threads, no
# threads::shared, no serialization). Call counts cross the fork boundary through a tiny counter
# file instead of shared memory, so assertions can still check "called exactly once" from the
# parent after the child exits. Fails closed: a request before install() answers 500 "no route
# installed", the same default every sibling mock-testing post in this series uses.
sub new {
my ($class) = @_;
my $d = HTTP::Daemon->new(LocalAddr => '127.0.0.1', ReuseAddr => 1, Timeout => 8)
or die "HTTP::Daemon: $!";
my ($fh, $count_file) = (undef, "/tmp/fakeserver-calls-$$-" . int(rand(1e9)));
open($fh, '>', $count_file) or die $!;
close($fh);
return bless { daemon => $d, count_file => $count_file, pid => undef }, $class;
}
sub base { return $_[0]->{daemon}->url }
# Forks a child that serves up to $n requests with $route (endpoint, params -> (status, body,
# retry_after_seconds)), then exits. The parent returns at once; call join() after driving the
# client to reap the child and make call_count() accurate.
sub run_in_child {
my ($self, $route, $n) = @_;
$route //= sub { return (500, '{"success":false,"message":"no route installed"}', 0) };
my $pid = fork();
die "fork: $!" unless defined $pid;
if ($pid == 0) {
for (1 .. $n) {
my $c = $self->{daemon}->accept or last;
my $r = $c->get_request;
if ($r) {
# $r->uri->path can come back EMPTY here: the quickstart's own base URL already
# ends in "/" and appends "/$endpoint", so the request line is a double-slash
# path ("//amazon-product-lookup"); URI then parses that as a scheme-relative
# reference with an empty authority, not a normal path. Stripping query string
# and ALL leading slashes from the raw URI string is robust to that quirk.
my $path = $r->uri->as_string;
$path =~ s/\?.*$//;
$path =~ s{^/+}{};
my %params = $r->uri->query_form;
open(my $cf, '>>', $self->{count_file}) or die $!;
flock($cf, LOCK_EX);
print $cf "$path\n";
close($cf);
my ($status, $body, $retry_after) = $route->($path, \%params, $r);
my $resp = HTTP::Response->new($status, undef, [], $body);
$resp->header('Content-Type' => 'application/json');
$resp->header('Retry-After' => $retry_after) if $retry_after && $retry_after > 0;
$c->send_response($resp);
}
$c->close;
}
exit(0);
}
$self->{pid} = $pid;
return;
}
sub join_server {
my ($self) = @_;
if (defined $self->{pid}) {
waitpid($self->{pid}, 0);
$self->{pid} = undef;
}
}
sub call_count {
my ($self, $endpoint) = @_;
$self->join_server; # a count read before the child exits could race a request in flight
open(my $fh, '<', $self->{count_file}) or return 0;
my $n = 0;
while (my $line = <$fh>) {
chomp $line;
$n++ if $line eq $endpoint;
}
close($fh);
return $n;
}
sub stop {
my ($self) = @_;
$self->join_server;
unlink($self->{count_file}) if $self->{count_file};
$self->{daemon} = undef;
}
1;

What does a full scenario suite look like, with no CPAN mocking library?
Each test creates its own FakeServer, forks it for exactly as many requests as the scenario expects (including the extra request a refunded 500 or a free 429 causes SellerMagnet::Retry to make), and stops it in the end. The 429, 500 and 502 scenarios run SellerMagnet::Retry's real backoff rather than shrinking it, so a pass is proof the actual wait and Retry-After handling work, at the cost of a few real seconds per test. A dedicated concurrency test drives five threads workers (the quickstart's own bulk-lookup pattern, one client per thread) against the fake to prove its flock-guarded counter file is safe under real concurrent requests.
MockApiTests.pl - the scenario suite, run for real below
#!/usr/bin/env perl
# Scenario suite for SellerMagnet / SellerMagnet::Retry / SellerMagnet::ApiError - every one of
# those files is the unmodified quickstart source. Only FakeServer.pm (new) stands in for the
# live API, through the constructor's own documented "base" test seam. No Test::More: a tiny
# runner below finds and calls every sub named test_*, matching the "standard library is
# enough" pitch every sibling mock-testing post in this series makes for its own language.
use strict;
use warnings;
use lib '.';
use SellerMagnet;
use SellerMagnet::Retry qw(get_with_retry);
use FakeServer;
use JSON::PP qw(encode_json);
use Time::HiRes qw(time);
my $ASIN = 'B0CL61F39H';
my $MP = 'ATVPDKIKX0DER';
sub product_json {
my ($price) = @_;
return encode_json({
success => \1,
data => {
productInfo => {
asin => $ASIN,
title => 'PlayStation5 console (slim)',
link => "https://www.amazon.com/dp/$ASIN",
buyBoxInfo => {
price => $price,
currencyCode => ($price eq 'N/A' ? 'N/A' : 'USD'),
sellerId => ($price eq 'N/A' ? 'N/A' : 'Amazon'),
},
},
},
});
}
sub assert_eq {
my ($got, $want, $msg) = @_;
die "FAIL: $msg (got " . (defined $got ? $got : 'undef') . ", want " . (defined $want ? $want : 'undef') . ")\n"
unless (defined $got && defined $want && $got eq $want) || (!defined $got && !defined $want);
}
sub test_happy_path_parses_the_real_response_shape {
my $fs = FakeServer->new;
$fs->run_in_child(sub { return (200, product_json(444.99), 0) }, 1);
my $client = SellerMagnet->new(key => 'test-key', base => $fs->base);
my $data = get_with_retry($client, 'amazon-product-lookup', asin => $ASIN, marketplaceId => $MP);
assert_eq($data->{productInfo}{asin}, $ASIN, 'asin');
assert_eq($data->{productInfo}{buyBoxInfo}{price}, 444.99, 'price');
assert_eq($fs->call_count('amazon-product-lookup'), 1, 'call count');
$fs->stop;
}
sub test_no_featured_offer_price_is_not_a_number {
my $fs = FakeServer->new;
$fs->run_in_child(sub { return (200, product_json('N/A'), 0) }, 1);
my $client = SellerMagnet->new(key => 'test-key', base => $fs->base);
my $data = get_with_retry($client, 'amazon-product-lookup', asin => $ASIN, marketplaceId => $MP);
my $price = $data->{productInfo}{buyBoxInfo}{price};
die "FAIL: price should read as the string N/A, not a number\n" unless $price eq 'N/A';
$fs->stop;
}
sub test_404_is_billed_and_must_not_be_retried {
my $fs = FakeServer->new;
$fs->run_in_child(sub {
return (404, encode_json({ success => \0, message => 'Product not found.' }), 0);
}, 1);
my $client = SellerMagnet->new(key => 'test-key', base => $fs->base);
eval { get_with_retry($client, 'amazon-product-lookup', asin => $ASIN, marketplaceId => $MP) };
my $err = $@;
die "FAIL: expected a SellerMagnet::ApiError\n" unless ref($err) && $err->isa('SellerMagnet::ApiError');
assert_eq($err->status, 404, '404 status');
assert_eq($fs->call_count('amazon-product-lookup'), 1, '404 not retried');
assert_eq($client->billed, 1, '404 is billed');
$fs->stop;
}
sub test_free_gate_400_missing_marketplace_id_is_not_retried {
my $fs = FakeServer->new;
$fs->run_in_child(sub {
return (400, encode_json({ success => \0, message => 'Missing required parameter: marketplaceId' }), 0);
}, 1);
my $client = SellerMagnet->new(key => 'test-key', base => $fs->base);
eval { get_with_retry($client, 'amazon-product-lookup', asin => $ASIN) };
my $err = $@;
assert_eq($err->status, 400, 'gate 400 status');
assert_eq($fs->call_count('amazon-product-lookup'), 1, 'gate 400 not retried');
assert_eq($client->billed, 0, 'free gate 400 is NOT billed');
$fs->stop;
}
sub test_endpoint_400_invalid_asin_is_billed_unlike_the_free_gate {
my $fs = FakeServer->new;
$fs->run_in_child(sub {
return (400, encode_json({ success => \0, message => 'Invalid product ASIN' }), 0);
}, 1);
my $client = SellerMagnet->new(key => 'test-key', base => $fs->base);
eval { get_with_retry($client, 'amazon-product-lookup', asin => 'bad', marketplaceId => $MP) };
my $err = $@;
assert_eq($err->status, 400, 'endpoint 400 status');
assert_eq($client->billed, 1, 'endpoint-own 400 IS billed, unlike the free gate 400');
$fs->stop;
}
sub test_401_invalid_key_is_free_and_not_retried {
my $fs = FakeServer->new;
$fs->run_in_child(sub {
return (401, encode_json({ success => \0, message => 'Invalid or inactive API key.' }), 0);
}, 1);
my $client = SellerMagnet->new(key => 'wrong-key', base => $fs->base);
eval { get_with_retry($client, 'amazon-product-lookup', asin => $ASIN, marketplaceId => $MP) };
my $err = $@;
assert_eq($err->status, 401, '401 status');
assert_eq($fs->call_count('amazon-product-lookup'), 1, '401 not retried');
assert_eq($client->billed, 0, '401 is free');
$fs->stop;
}
sub test_429_concurrency_cap_is_free_and_retried_with_a_real_wait {
my $fs = FakeServer->new;
my $first = 1;
$fs->run_in_child(sub {
if ($first) {
$first = 0;
return (429, encode_json({ success => \0, message => 'Max 5 concurrent requests per API key.' }), 1);
}
return (200, encode_json({ success => \1, data => { ok => \1 } }), 0);
}, 2);
my $client = SellerMagnet->new(key => 'test-key', base => $fs->base);
my $start = time();
get_with_retry($client, 'amazon-product-lookup', asin => $ASIN, marketplaceId => $MP);
my $elapsed = time() - $start;
die sprintf("FAIL: elapsed=%.2fs, want >= 1s (real Retry-After wait, not shrunk)\n", $elapsed)
if $elapsed < 1.0;
assert_eq($fs->call_count('amazon-product-lookup'), 2, '429 retried exactly once');
assert_eq($client->billed, 1, 'the free 429 does not count, only the successful (200) retry is billed');
$fs->stop;
}
sub test_500_is_refunded_and_retried_exactly_once {
my $fs = FakeServer->new;
my $first = 1;
$fs->run_in_child(sub {
if ($first) {
$first = 0;
return (500, encode_json({ success => \0, message => 'internal error' }), 0);
}
return (200, encode_json({ success => \1, data => { ok => \1 } }), 0);
}, 2);
my $client = SellerMagnet->new(key => 'test-key', base => $fs->base);
get_with_retry($client, 'amazon-product-lookup', asin => $ASIN, marketplaceId => $MP);
assert_eq($fs->call_count('amazon-product-lookup'), 2, '500 retried exactly once');
assert_eq($client->billed, 1, 'the refunded 500 does not count, only the second (successful) attempt is billed');
$fs->stop;
}
sub test_a_second_consecutive_500_stops_instead_of_looping {
my $fs = FakeServer->new;
$fs->run_in_child(sub {
return (500, encode_json({ success => \0, message => 'internal error' }), 0);
}, 2);
my $client = SellerMagnet->new(key => 'test-key', base => $fs->base);
eval { get_with_retry($client, 'amazon-product-lookup', asin => $ASIN, marketplaceId => $MP) };
my $err = $@;
assert_eq($err->status, 500, 'second 500 status');
assert_eq($fs->call_count('amazon-product-lookup'), 2, 'first 500 + one retry, then stop');
$fs->stop;
}
sub test_502_is_billed_on_every_attempt_up_to_the_cap {
my $fs = FakeServer->new;
$fs->run_in_child(sub {
return (502, encode_json({ success => \0, message => 'upstream error' }), 0);
}, 4);
my $client = SellerMagnet->new(key => 'test-key', base => $fs->base);
eval { get_with_retry($client, 'amazon-product-lookup', asin => $ASIN, marketplaceId => $MP) };
my $err = $@;
assert_eq($err->status, 502, '502 status');
assert_eq($fs->call_count('amazon-product-lookup'), 4, 'capped at 4 attempts');
assert_eq($client->billed, 4, 'billed on every attempt');
$fs->stop;
}
sub test_statistics_prices_are_integer_cents_not_decimal {
my $fs = FakeServer->new;
$fs->run_in_child(sub {
return (200, encode_json({
success => \1,
data => { asin => $ASIN, buyBoxPrice => 41800, buyBoxFulfillment => 'FBA' },
}), 0);
}, 1);
my $client = SellerMagnet->new(key => 'test-key', base => $fs->base);
my $stats = get_with_retry($client, 'amazon-product-statistics', asin => $ASIN, marketplaceId => $MP);
assert_eq($stats->{buyBoxPrice}, 41800, 'raw minor units');
die "FAIL: 41800/100 should be 418\n" unless ($stats->{buyBoxPrice} / 100) == 418;
$fs->stop;
}
sub test_japan_statistics_price_is_whole_yen_not_divided_by_100 {
my $fs = FakeServer->new;
$fs->run_in_child(sub {
return (200, encode_json({
success => \1,
data => { asin => $ASIN, buyBoxPrice => 54800, buyBoxFulfillment => 'FBA' },
}), 0);
}, 1);
my $client = SellerMagnet->new(key => 'test-key', base => $fs->base);
my $stats = get_with_retry($client, 'amazon-product-statistics', asin => $ASIN, marketplaceId => 'A1VC38T7YXB528');
# the quickstart's own main.pl divides by 100 everywhere EXCEPT amazon.co.jp
# (marketplaceId A1VC38T7YXB528), where the integer IS already whole yen.
assert_eq($stats->{buyBoxPrice}, 54800, 'JP whole-yen value unchanged by the fake');
$fs->stop;
}
sub test_malformed_asin_is_skipped_before_any_call_is_billed {
my $fs = FakeServer->new;
$fs->run_in_child(sub { return (200, product_json(444.99), 0) }, 0);
# "4.00638E+12" is Excel scientific notation for a barcode, not a 10-char ASIN: is_asin
# must reject it before any network call, so FakeServer never even receives a request.
die "FAIL: is_asin should reject Excel scientific notation\n"
if SellerMagnet::is_asin('4.00638E+12');
$fs->stop;
}
sub test_trailing_newline_asin_is_rejected_by_the_anchored_regex {
# Perl's ^...$ still matches before a trailing \n; \A...\z (what is_asin actually uses)
# does not. A value read from a file with a stray newline must not slip through.
die "FAIL: is_asin should reject a trailing-newline ASIN (\\A...\\z, not ^...\$)\n"
if SellerMagnet::is_asin("B0CL61F39H\n");
die "FAIL: is_asin should accept a clean 10-character ASIN\n"
unless SellerMagnet::is_asin('B0CL61F39H');
}
sub test_fake_server_fails_closed_without_install {
my $fs = FakeServer->new;
$fs->run_in_child(undef, 2); # no route given: the default BLOCKED 500 is refunded + retried once
my $client = SellerMagnet->new(key => 'test-key', base => $fs->base);
eval { get_with_retry($client, 'amazon-product-lookup', asin => $ASIN, marketplaceId => $MP) };
my $err = $@;
assert_eq($err->status, 500, 'fails closed status');
die "FAIL: message should mention 'no route installed'\n"
unless $err->message =~ /no route installed/;
$fs->stop;
}
sub test_five_threads_against_the_shared_fake_server {
my $fs = FakeServer->new;
$fs->run_in_child(sub {
my ($endpoint, $params) = @_;
return (404, encode_json({ success => \0, message => 'Product not found.' }), 0)
if $params->{asin} eq 'B0UNKNOWN1';
return (200, product_json(444.99), 0);
}, 5);
require threads;
require Thread::Queue;
my @asins = ('B0CL61F39H', 'B0AAAAAAA1', 'B0AAAAAAA2', 'B0UNKNOWN1', 'B0AAAAAAA3');
my $jobs = Thread::Queue->new(@asins);
$jobs->end;
my $rows = Thread::Queue->new;
my @workers = map {
threads->create(sub {
my $client = SellerMagnet->new(key => 'test-key', base => $fs->base); # one client per thread
while (defined(my $asin = $jobs->dequeue)) {
my $ok = eval { get_with_retry($client, 'amazon-product-lookup', asin => $asin, marketplaceId => $MP); 1 };
$rows->enqueue({ asin => $asin, ok => ($ok ? 1 : 0) });
}
});
} (1 .. 5);
$_->join for @workers;
my @results;
while (defined(my $row = $rows->dequeue_nb)) { push @results, $row; }
assert_eq(scalar(@results), 5, 'five rows back');
assert_eq($fs->call_count('amazon-product-lookup'), 5, 'every thread landed exactly once, none lost');
my $errors = grep { !$_->{ok} } @results;
assert_eq($errors, 1, 'only B0UNKNOWN1 failed');
$fs->stop;
}
# --- tiny reflection-free runner: every sub named test_* above is found and run in name order ---
no strict 'refs';
my @names = sort grep { /^test_/ } keys %main::;
my ($pass, $fail) = (0, 0);
my @results;
for my $name (@names) {
my $start = time();
my $ok = eval { &{"main::$name"}(); 1 };
my $elapsed = time() - $start;
if ($ok) {
$pass++;
push @results, sprintf("PASS %-58s (%.2fs)", $name, $elapsed);
} else {
$fail++;
my $msg = $@;
$msg =~ s/\n$//;
push @results, sprintf("FAIL %-58s %s", $name, $msg);
}
}
my $total = time();
print "$_\n" for @results;
print "\n$pass passed, $fail failed\n";
exit($fail == 0 ? 0 : 1);
perl MockApiTests.pl output (unmodified run)
PASS test_401_invalid_key_is_free_and_not_retried (0.16s)
PASS test_404_is_billed_and_must_not_be_retried (0.03s)
PASS test_429_concurrency_cap_is_free_and_retried_with_a_real_wait (1.05s)
PASS test_500_is_refunded_and_retried_exactly_once (0.03s)
PASS test_502_is_billed_on_every_attempt_up_to_the_cap (6.20s)
PASS test_a_second_consecutive_500_stops_instead_of_looping (0.09s)
PASS test_endpoint_400_invalid_asin_is_billed_unlike_the_free_gate (0.06s)
PASS test_fake_server_fails_closed_without_install (0.05s)
PASS test_five_threads_against_the_shared_fake_server (0.30s)
PASS test_free_gate_400_missing_marketplace_id_is_not_retried (0.25s)
PASS test_happy_path_parses_the_real_response_shape (0.22s)
PASS test_japan_statistics_price_is_whole_yen_not_divided_by_100 (0.25s)
PASS test_malformed_asin_is_skipped_before_any_call_is_billed (0.16s)
PASS test_no_featured_offer_price_is_not_a_number (0.20s)
PASS test_statistics_prices_are_integer_cents_not_decimal (0.09s)
PASS test_trailing_newline_asin_is_rejected_by_the_anchored_regex (0.00s)
16 passed, 0 failed
Never hand-write a fake of get_once() or get_with_retry() itself
A fake that reimplements get_once() or get_with_retry() tests the fake's own logic, not the real client. Fake one layer below your code - here, the HTTP server it talks to - so a real bug in the decoding or retry logic still shows up as a failing test.
Does the same pattern work for other languages?
Yes, fake the one call the real code makes to the network, whichever shape that takes. The Python guide fakes requests.Session.get, the Go guide fakes http.RoundTripper, the PHP guide points Guzzle at a local php -S process, the Ruby guide prepends a fake onto Net::HTTP, and the Rust guide points reqwest at a real local mockito server; this guide forks a real local HTTP::Daemon instead, since Perl's ithreads rule out a shared-memory server thread. The 429/Retry-After guide and the 502/503 retry guide are the production behaviour this suite checks against; keep all of these in sync when the retry logic changes. Credit costs and the free trial are on the pricing page, and every endpoint's parameters are in the API documentation and code examples.
Frequently Asked Questions
Can Perl tests call the real SellerMagnet API instead of faking it?
They can, but every call is billed the same as production traffic, so a CI run that fires on every push spends credits on every build, and a 429 or a second 500 in a row cannot be forced on demand against the live API. A local HTTP::Daemon fake lets every billed, free and refunded status show up on demand while SellerMagnet.pm and SellerMagnet::Retry from the Perl quickstart run completely unmodified.
Why fake a local HTTP::Daemon instead of mocking LWP::UserAgent itself?
SellerMagnet.pm already documents its own test seam: "new(base => ...)" (or the SELLERMAGNET_API_BASE env var) only for pointing the client at a local mock server in tests. FakeServer.pm generalizes that seam into a per-test scriptable real HTTP server, so LWP::UserAgent still makes a real socket connection and a real HTTP round trip - a mocked UserAgent object would stop testing the actual request building, header, timeout and JSON-decoding code the quickstart ships.
Why does the fake server run in a forked child process, not a thread?
Perl's ithreads clone the whole interpreter on create, so a route installed in the main thread is invisible to a server loop running in a second thread - there is no shared memory by default. fork() instead duplicates the already-bound HTTP::Daemon listening socket into a child that serves exactly as many requests as a test expects, while the quickstart's own client runs unmodified in the parent. A small counter file crosses the fork boundary so a test can still assert "called exactly once" after the child exits.
How do I avoid real waits for a 429 or 500 retry test?
This suite does not shrink SellerMagnet::Retry's own backoff: a passing 429/500/502 test is proof the actual wait and Retry-After handling work, not just that the code path was reached. Expect those tests to take a few real seconds each, and the 502 test (billed and retried to the attempt cap) to take the longest of the whole suite.
Does the fake server handle the quickstart's own multi-threaded client safely?
Yes. The bulk example gives every thread its own SellerMagnet client (LWP::UserAgent is not documented thread-safe), and FakeServer serves each of those requests from its own forked child, counting hits in a flock-guarded file rather than in-process memory - safe under concurrent requests from multiple threads for the same reason fork avoids the ithreads cloning problem in the first place.
Should the fake answer anything if a test forgets to install a route?
No. FakeServer defaults to a route that answers 500 "no route installed", the same fail-closed default every sibling mock-testing post in this series uses. A forgotten install() then fails the test loudly - and, since a 500 is retried once by SellerMagnet::Retry, the fake must still be told to expect that second call.
Bottom line: generalize whatever local test seam your language's quickstart already documents (here, the Perl quickstart's own base => ... argument) into a per-test scriptable fake, forking a real local server when the language's own threading model rules out a shared-memory one, and run the real client code against scripted responses for every billed, free and refunded status. The whole suite above runs in about 8 seconds - most of it real retry waits it refuses to fake - and spends zero credits, with nothing beyond core Perl and libwww-perl.