import org.bouncycastle.util.encoders.Hex;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import io.github.bitcoineducation.bitcoinjava.VarInt;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.math.BigInteger;
import java.util.stream.Stream;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class VarIntTest {
@ParameterizedTest
@MethodSource("testStreamParameters")
public void fromByteStream(String hex, BigInteger expectedResult) throws IOException {
assertEquals(
expectedResult,
VarInt.fromByteStream(new ByteArrayInputStream(Hex.decodeStrict(hex)))
);
}
@ParameterizedTest
@MethodSource("testStreamParameters")
public void toByteStream(String expectedResult, BigInteger bigInteger) {
assertEquals(
expectedResult,
VarInt.toHex(bigInteger)
);
}
private static Stream