Skip to content

Commit

Permalink
Apply clang-format to the project.
Browse files Browse the repository at this point in the history
  • Loading branch information
danlapid committed Aug 20, 2024
1 parent e81a776 commit 72d13e7
Show file tree
Hide file tree
Showing 362 changed files with 22,532 additions and 22,735 deletions.
21 changes: 11 additions & 10 deletions src/workerd/api/actor-state-iocontext-test.c++
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ namespace {
using workerd::TestFixture;

bool contains(kj::StringPtr haystack, kj::StringPtr needle) {
return std::search(haystack.begin(), haystack.end(), needle.begin(), needle.end())
!= haystack.end();
return std::search(haystack.begin(), haystack.end(), needle.begin(), needle.end()) !=
haystack.end();
}

class MockActorId : public ActorIdFactory::ActorId {
class MockActorId: public ActorIdFactory::ActorId {
public:
MockActorId(kj::String id) : id(kj::mv(id)) {}
MockActorId(kj::String id): id(kj::mv(id)) {}
kj::String toString() const override {
return kj::str("MockActorId<", id, ">");
}
Expand All @@ -41,6 +41,7 @@ public:
}

virtual ~MockActorId() {};

private:
kj::String id;
};
Expand All @@ -63,9 +64,9 @@ void runBadDeserialization(jsg::Lock& lock, kj::StringPtr expectedId) {

void runBadDeserializationInIoContext(TestFixture& fixture, kj::StringPtr expectedId) {
fixture.runInIoContext(
[expectedId](const workerd::TestFixture::Environment& env) -> kj::Promise<void> {
runBadDeserialization(env.lock, expectedId);
return kj::READY_NOW;
[expectedId](const workerd::TestFixture::Environment& env) -> kj::Promise<void> {
runBadDeserialization(env.lock, expectedId);
return kj::READY_NOW;
});
}

Expand All @@ -88,10 +89,10 @@ KJ_TEST("actor specified with ActorId object") {
kj::Own<ActorIdFactory::ActorId> mockActorId = kj::heap<MockActorId>(kj::str("testActorId"));
Worker::Actor::Id id = kj::mv(mockActorId);
TestFixture fixture(TestFixture::SetupParams{
.actorId = kj::mv(id),
.actorId = kj::mv(id),
});
runBadDeserializationInIoContext(fixture, "actorId = MockActorId<testActorId>;"_kj);
}

} // namespace
} // namespace workerd::api
} // namespace
} // namespace workerd::api
16 changes: 6 additions & 10 deletions src/workerd/api/actor-state-test.c++
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,23 @@ namespace {
jsg::V8System v8System;

struct ActorStateContext: public jsg::Object, public jsg::ContextGlobal {
JSG_RESOURCE_TYPE(ActorStateContext) {
}
JSG_RESOURCE_TYPE(ActorStateContext) {}
};
JSG_DECLARE_ISOLATE_TYPE(ActorStateIsolate, ActorStateContext);

KJ_TEST("v8 serialization version tag hasn't changed") {
jsg::test::Evaluator<ActorStateContext, ActorStateIsolate> e(v8System);
e.getIsolate().runInLockScope([&](ActorStateIsolate::Lock& isolateLock) {
JSG_WITHIN_CONTEXT_SCOPE(isolateLock,
isolateLock.newContext<ActorStateContext>().getHandle(isolateLock),
[&](jsg::Lock& js) {
isolateLock.newContext<ActorStateContext>().getHandle(isolateLock), [&](jsg::Lock& js) {
auto buf = serializeV8Value(isolateLock, isolateLock.boolean(true));

// Confirm that a version header is appropriately written and that it contains the expected
// current version. When the version increases, we need to write a v8 patch that allows it
// to continue writing data at the old version so that we can do a rolling upgrade without
// any bugs caused by old processes failing to read data written by new ones.
KJ_EXPECT(buf[0] == 0xFF);
KJ_EXPECT(buf[1] == 0x0F); // v8 serializer version
KJ_EXPECT(buf[1] == 0x0F); // v8 serializer version

// And this just confirms that the deserializer agrees on the version.
v8::ValueDeserializer deserializer(isolateLock.v8Isolate, buf.begin(), buf.size());
Expand All @@ -61,15 +59,14 @@ KJ_TEST("we support deserializing up to v15") {
jsg::test::Evaluator<ActorStateContext, ActorStateIsolate> e(v8System);
e.getIsolate().runInLockScope([&](ActorStateIsolate::Lock& isolateLock) {
JSG_WITHIN_CONTEXT_SCOPE(isolateLock,
isolateLock.newContext<ActorStateContext>().getHandle(isolateLock),
[&](jsg::Lock& js) {
isolateLock.newContext<ActorStateContext>().getHandle(isolateLock), [&](jsg::Lock& js) {
kj::Vector<kj::StringPtr> testCases;
testCases.add("54");
testCases.add("FF0D54");
testCases.add("FF0E54");
testCases.add("FF0F54");

for (const auto& hexStr : testCases) {
for (const auto& hexStr: testCases) {
auto dataIn = kj::decodeHex(hexStr.asArray());
KJ_EXPECT(deserializeV8Value(isolateLock, "some-key"_kj, dataIn).isTrue());
}
Expand Down Expand Up @@ -104,8 +101,7 @@ KJ_TEST("wire format version does not change deserialization behavior on real da
jsg::test::Evaluator<ActorStateContext, ActorStateIsolate> e(v8System);
e.getIsolate().runInLockScope([&](ActorStateIsolate::Lock& isolateLock) {
JSG_WITHIN_CONTEXT_SCOPE(isolateLock,
isolateLock.newContext<ActorStateContext>().getHandle(isolateLock),
[&](jsg::Lock& js) {
isolateLock.newContext<ActorStateContext>().getHandle(isolateLock), [&](jsg::Lock& js) {
// Read in data line by line and verify that it round trips (serializes and
// then deserializes) back to the exact same data as the input.
std::string hexStr;
Expand Down
Loading

0 comments on commit 72d13e7

Please sign in to comment.