fix(import): a deleted DXCC entity is not re-stamped from cty.dat

Reported with a Logger32 export: the record said <DXCC:3>151 and OpsLog
stored 54.

cty.dat answers one question — where is this callsign TODAY — and that is
the wrong question for a log. R1MVI was Malyj Vysotskij Island, entity
151, until the ARRL deleted it in 2012; the same call resolves to European
Russia today. Forcing the lookup onto a 2004 contact therefore destroys a
credit that can NEVER be worked again, because the place no longer counts.

So the ADIF's number wins whenever it names a deleted entity, and nothing
is corrected on those records at all — the country name and the zones of a
deleted entity are equally beyond what a present-day prefix table knows.
The list is the ADIF specification's own enumeration, sixty-odd entities
that only change when the ARRL deletes another one.

The guard sits in the forced path, so it also covers the grid's 'Update
from cty.dat' on a selection — the other way an operator could have lost
the same credits, one right-click at a time.
This commit is contained in:
2026-08-26 21:59:53 +02:00
parent 4a28b51ade
commit c1cd76bbcf
4 changed files with 162 additions and 2 deletions
+46
View File
@@ -0,0 +1,46 @@
package dxcc
import "testing"
// The contact that reported this: R1MVI, worked in 2004 on Malyj Vysotskij
// Island, entity 151, deleted in February 2012. cty.dat resolves that callsign
// to European Russia (54) today, so anything that re-stamps an old QSO from a
// callsign has to know to stop here.
func TestMalyjVysotskijIsKnownDeleted(t *testing.T) {
if !IsDeleted(151) {
t.Fatal("151 (Malyj Vysotskij I.) must be known as deleted — the whole guard hangs on it")
}
if got := DeletedName(151); got == "" {
t.Error("a deleted entity should be able to say what it was called")
}
}
// The guard must not fire on entities that are alive, or every log would freeze
// at whatever DXCC number it was imported with — including the wrong ones.
func TestLiveEntitiesAreNotTreatedAsDeleted(t *testing.T) {
live := map[int]string{
54: "European Russia — what R1MVI resolves to today",
227: "France",
291: "United States",
339: "Japan",
1: "Canada",
}
for n, what := range live {
if IsDeleted(n) {
t.Errorf("%d (%s) must not be listed as deleted", n, what)
}
}
if got := DeletedName(54); got != "" {
t.Errorf("DeletedName(54) = %q, want empty", got)
}
}
// A few more from the ADIF enumeration, so a careless edit to the table is
// caught rather than discovered by an operator whose credits moved.
func TestSomeOtherDeletedEntities(t *testing.T) {
for _, n := range []int{218 /* Czechoslovakia */, 229 /* German DR */, 255 /* St. Maarten, Saba, St. Eustatius */, 28 /* Canal Zone */} {
if !IsDeleted(n) {
t.Errorf("%d should be a deleted entity", n)
}
}
}