-ok($im->add($mime), 'added one message');
-$mime->body_set("hello world!\n");
-
-my @warn;
-local $SIG{__WARN__} = sub { push @warn, @_ };
-$mime->header_set(Date => 'Fri, 02 Oct 1993 00:01:00 +0000');
-ok($im->add($mime), 'added duplicate-but-different message');
-is(scalar(@warn), 1, 'got one warning');
-my $mids = mids($mime->header_obj);
-$new_mid = $mids->[1];
-$im->done;
+my $new_mid;
+my $ibx = create_inbox 'v2-1', version => 2, indexlevel => 'medium',
+ tmpdir => "$tmpdir/v2", sub {
+ my ($im, $ibx) = @_;
+ $im->add($eml) or BAIL_OUT;
+ $eml->body_set("hello world!\n");
+ my @warn;
+ local $SIG{__WARN__} = sub { push @warn, @_ };
+ $eml->header_set(Date => 'Fri, 02 Oct 1993 00:01:00 +0000');
+ $im->add($eml) or BAIL_OUT;
+ is(scalar(@warn), 1, 'got one warning');
+ my $mids = mids($eml->header_obj);
+ $new_mid = $mids->[1];
+ open my $fh, '>', "$ibx->{inboxdir}/new_mid" or BAIL_OUT;
+ print $fh $new_mid or BAIL_OUT;
+ close $fh or BAIL_OUT;
+};
+$new_mid //= do {
+ open my $fh, '<', "$ibx->{inboxdir}/new_mid" or BAIL_OUT;
+ local $/;
+ <$fh>;
+};
+my $cfgpath = "$ibx->{inboxdir}/pi_config";
+{
+ open my $fh, '>', $cfgpath or BAIL_OUT $!;
+ print $fh <<EOF or BAIL_OUT $!;
+[publicinbox "v2test"]
+ inboxdir = $ibx->{inboxdir}
+ address = $ibx->{-primary_address}
+[publicinbox "dup"]
+ inboxdir = $dibx->{inboxdir}
+ address = $dibx->{-primary_address}
+EOF
+ close $fh or BAIL_OUT;
+}