Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: mockingbirdnest/Principia
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 17b20a631168
Choose a base ref
...
head repository: mockingbirdnest/Principia
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 8841754eb596
Choose a head ref
  • 5 commits
  • 2 files changed
  • 1 contributor

Commits on Oct 19, 2021

  1. Copy the full SHA
    b4eacb2 View commit details
  2. Numbers.

    pleroy committed Oct 19, 2021
    Copy the full SHA
    b798530 View commit details
  3. After egg's review.

    pleroy committed Oct 19, 2021
    Copy the full SHA
    243a39e View commit details
  4. Proper version check.

    pleroy committed Oct 19, 2021
    Copy the full SHA
    5acb7ea View commit details

Commits on Oct 20, 2021

  1. Merge pull request #3159 from pleroy/Lpg

    A test to produce a pre-Ζήνων trajectory
    pleroy authored Oct 20, 2021
    Copy the full SHA
    8841754 View commit details
Showing with 59 additions and 5 deletions.
  1. +55 −3 ksp_plugin_test/plugin_compatibility_test.cpp
  2. +4 −2 physics/discrete_trajectory_body.hpp
58 changes: 55 additions & 3 deletions ksp_plugin_test/plugin_compatibility_test.cpp
Original file line number Diff line number Diff line change
@@ -6,15 +6,19 @@

#include "astronomy/time_scales.hpp"
#include "astronomy/mercury_orbiter.hpp"
#include "base/array.hpp"
#include "base/file.hpp"
#include "base/not_null.hpp"
#include "base/pull_serializer.hpp"
#include "base/push_deserializer.hpp"
#include "base/serialization.hpp"
#include "glog/logging.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "ksp_plugin/frames.hpp"
#include "ksp_plugin/interface.hpp"
#include "ksp_plugin/plugin.hpp"
#include "physics/discrete_trajectory.hpp"
#include "serialization/ksp_plugin.pb.h"
#include "testing_utilities/is_near.hpp"
#include "testing_utilities/serialization.hpp"
@@ -30,15 +34,20 @@ using astronomy::date_time::DateTime;
using astronomy::date_time::operator""_DateTime;
using base::not_null;
using base::OFStream;
using base::ParseFromBytes;
using base::PullSerializer;
using base::PushDeserializer;
using ksp_plugin::Barycentric;
using ksp_plugin::Plugin;
using physics::DiscreteTrajectory;
using quantities::Speed;
using quantities::si::Kilo;
using testing_utilities::operator""_⑴;
using testing_utilities::IsNear;
using testing_utilities::ReadFromBinaryFile;
using testing_utilities::ReadLinesFromBase64File;
using testing_utilities::ReadLinesFromHexadecimalFile;
using testing_utilities::WriteToBinaryFile;
using ::testing::AllOf;
using ::testing::ElementsAre;
using ::testing::Eq;
@@ -287,10 +296,8 @@ TEST_F(PluginCompatibilityTest, DISABLED_Butcher) {
R"(P:\Public Mockingbird\Principia\Saves\1119\1119.proto.b64)",
/*compressor=*/"gipfeli",
/*decoder=*/"base64");
// TODO(phl): Check that we mention a compatibility path here once something
// changes.
EXPECT_THAT(log_warning.string(),
Not(HasSubstr("pre-Gröbner")));
AllOf(HasSubstr("pre-Haar"), Not(HasSubstr("pre-Gröbner"))));
auto const& orbiter =
*plugin->GetVessel("e180ca12-492f-45bf-a194-4c5255aec8a0");
EXPECT_THAT(orbiter.name(), Eq("Mercury Orbiter 1"));
@@ -348,6 +355,51 @@ TEST_F(PluginCompatibilityTest, DISABLED_Butcher) {
WriteAndReadBack(std::move(plugin));
}

TEST_F(PluginCompatibilityTest, DISABLED_Lpg) {
StringLogSink log_warning(google::WARNING);
not_null<std::unique_ptr<Plugin const>> plugin = ReadPluginFromFile(
R"(P:\Public Mockingbird\Principia\Saves\3136\3136.proto.b64)",
/*compressor=*/"gipfeli",
/*decoder=*/"base64");
// TODO(phl): Check that we mention a compatibility path here once something
// changes.
EXPECT_THAT(log_warning.string(),
Not(HasSubstr("pre-Haar")));

// The vessel with the longest history.
auto const& vessel =
*plugin->GetVessel("77ddea45-47ee-48c0-aee9-d55cdb35ffcd");
auto& psychohistory =
const_cast<DiscreteTrajectory<Barycentric>&>(vessel.psychohistory());
auto const history = psychohistory.root();
EXPECT_EQ(435'927, history->Size());
EXPECT_EQ(435'929, psychohistory.Size());

// Serialize the history and psychohistory to a temporary file.
{
serialization::DiscreteTrajectory message;
history->WriteToMessage(&message, /*forks=*/{&psychohistory}, /*exact=*/{});
auto const serialized_message = base::SerializeAsBytes(message);
WriteToBinaryFile(TEMP_DIR / "trajectory_3136.proto.bin",
serialized_message.get());
}

// Deserialize the temporary file to make sure that it's valid.
{
auto const serialized_message =
ReadFromBinaryFile(TEMP_DIR / "trajectory_3136.proto.bin");
auto const message =
ParseFromBytes<serialization::DiscreteTrajectory>(serialized_message);
DiscreteTrajectory<Barycentric>* psychohistory = nullptr;
auto const history = DiscreteTrajectory<Barycentric>::ReadFromMessage(
message, /*forks=*/{&psychohistory});
EXPECT_EQ(435'927, history->Size());
EXPECT_EQ(435'929, psychohistory->Size());
}

// Make sure that we can upgrade, save, and reload.
WriteAndReadBack(std::move(plugin));
}

// Use for debugging saves given by users.
TEST_F(PluginCompatibilityTest, DISABLED_SECULAR_Debug) {
6 changes: 4 additions & 2 deletions physics/discrete_trajectory_body.hpp
Original file line number Diff line number Diff line change
@@ -486,10 +486,12 @@ typename DiscreteTrajectory<Frame>::Downsampling
DiscreteTrajectory<Frame>::Downsampling::ReadFromMessage(
serialization::DiscreteTrajectory::Downsampling const& message,
Timeline const& timeline) {
bool const is_pre_grotendieck_haar = message.has_start_of_dense_timeline();
bool const is_pre_haar = message.has_start_of_dense_timeline();
LOG_IF(WARNING, is_pre_haar)
<< "Reading pre-Haar DiscreteTrajectory.Downsampling";
Downsampling downsampling({message.max_dense_intervals(),
Length::ReadFromMessage(message.tolerance())});
if (is_pre_grotendieck_haar) {
if (is_pre_haar) {
// No support for forks in legacy saves, so |find| will succeed and ++ is
// safe.
auto it = timeline.find(