cleanup: remove ConnID, DialID, TransactionID (#395)
We are not using them anymore. The only nettest still using the legacy netx implementation is tor, for which setting these fields is useless, because it performs each measurement into a separate goroutine. Hence, let us start removing this part of the legacy netx codebase, which is hampering progress in other areas. Occurred to me while doing testing for the recent changes in error mapping (https://github.com/ooni/probe/issues/1505).
This commit is contained in:
parent
1fefe5d9b8
commit
c74c94d616
32 changed files with 78 additions and 896 deletions
|
|
@ -143,12 +143,6 @@ var ErrDNSBogon = errors.New("dns: detected bogon address")
|
|||
// this structure is to properly set Failure, which is also returned by
|
||||
// the Error() method, so be one of the OONI defined strings.
|
||||
type ErrWrapper struct {
|
||||
// ConnID is the connection ID, or zero if not known.
|
||||
ConnID int64
|
||||
|
||||
// DialID is the dial ID, or zero if not known.
|
||||
DialID int64
|
||||
|
||||
// Failure is the OONI failure string. The failure strings are
|
||||
// loosely backward compatible with Measurement Kit.
|
||||
//
|
||||
|
|
@ -181,9 +175,6 @@ type ErrWrapper struct {
|
|||
// supposed to refer to the major operation that failed.
|
||||
Operation string
|
||||
|
||||
// TransactionID is the transaction ID, or zero if not known.
|
||||
TransactionID int64
|
||||
|
||||
// WrappedErr is the error that we're wrapping.
|
||||
WrappedErr error
|
||||
}
|
||||
|
|
@ -201,12 +192,6 @@ func (e *ErrWrapper) Unwrap() error {
|
|||
// SafeErrWrapperBuilder contains a builder for ErrWrapper that
|
||||
// is safe, i.e., behaves correctly when the error is nil.
|
||||
type SafeErrWrapperBuilder struct {
|
||||
// ConnID is the connection ID, if any
|
||||
ConnID int64
|
||||
|
||||
// DialID is the dial ID, if any
|
||||
DialID int64
|
||||
|
||||
// Error is the error, if any
|
||||
Error error
|
||||
|
||||
|
|
@ -216,9 +201,6 @@ type SafeErrWrapperBuilder struct {
|
|||
|
||||
// Operation is the operation that failed
|
||||
Operation string
|
||||
|
||||
// TransactionID is the transaction ID, if any
|
||||
TransactionID int64
|
||||
}
|
||||
|
||||
// MaybeBuild builds a new ErrWrapper, if b.Error is not nil, and returns
|
||||
|
|
@ -230,12 +212,9 @@ func (b SafeErrWrapperBuilder) MaybeBuild() (err error) {
|
|||
classifier = toFailureString
|
||||
}
|
||||
err = &ErrWrapper{
|
||||
ConnID: b.ConnID,
|
||||
DialID: b.DialID,
|
||||
Failure: classifier(b.Error),
|
||||
Operation: toOperationString(b.Error, b.Operation),
|
||||
TransactionID: b.TransactionID,
|
||||
WrappedErr: b.Error,
|
||||
Failure: classifier(b.Error),
|
||||
Operation: toOperationString(b.Error, b.Operation),
|
||||
WrappedErr: b.Error,
|
||||
}
|
||||
}
|
||||
return
|
||||
|
|
|
|||
|
|
@ -17,27 +17,15 @@ import (
|
|||
|
||||
func TestMaybeBuildFactory(t *testing.T) {
|
||||
err := SafeErrWrapperBuilder{
|
||||
ConnID: 1,
|
||||
DialID: 10,
|
||||
Error: errors.New("mocked error"),
|
||||
TransactionID: 100,
|
||||
Error: errors.New("mocked error"),
|
||||
}.MaybeBuild()
|
||||
var target *ErrWrapper
|
||||
if errors.As(err, &target) == false {
|
||||
t.Fatal("not the expected error type")
|
||||
}
|
||||
if target.ConnID != 1 {
|
||||
t.Fatal("wrong ConnID")
|
||||
}
|
||||
if target.DialID != 10 {
|
||||
t.Fatal("wrong DialID")
|
||||
}
|
||||
if target.Failure != "unknown_failure: mocked error" {
|
||||
t.Fatal("the failure string is wrong")
|
||||
}
|
||||
if target.TransactionID != 100 {
|
||||
t.Fatal("the transactionID is wrong")
|
||||
}
|
||||
if target.WrappedErr.Error() != "mocked error" {
|
||||
t.Fatal("the wrapped error is wrong")
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue